titanandrews
Programmer
Hi,
I am having a bit of trouble with this one. All I want to do is call a function that is in a dll that I created. The dll gets loaded put I cannot make the function call. What am I missing??
//Here is my dll code
//And here is my calling code in the executable
many thanks,
Barry
I am having a bit of trouble with this one. All I want to do is call a function that is in a dll that I created. The dll gets loaded put I cannot make the function call. What am I missing??
//Here is my dll code
Code:
#include <iostream>
void __declspec(dllexport)__stdcall doIt()
{
std::cout << "doIt function called " << std::endl;
}
//And here is my calling code in the executable
Code:
#include "afx.h"
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
HANDLE dllHandle;
typedef void (__stdcall *MY_PROC)(void);
MY_PROC doIt;
dllHandle = LoadLibrary((LPCTSTR) "MyDll.dll");
if (dllHandle == NULL)
{
cout << "MyDll.dll failed to load..." << endl;
exit(0);
}
doIt = (MY_PROC)GetProcAddress((HINSTANCE)dllHandle, "doIt");
if (doIt == NULL)
{
cout << "doIt failed..." << endl;
}
else doIt();
return(1);
}
many thanks,
Barry