tried both still same thing : /
Edit:
Now its working!
code:
DLL main.cpp
1 2 3 4 5 6 7 8 9
|
extern "C" __declspec(dllexport) bool GetWelcomeMessage(char *buf, int len)
{
if(buf != NULL && len > 48)
{
strcpy(buf, "Welcome Message From My First DLL function\n");
return true;
}
return false;
}
|
APP main.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
int main(int argc, char** argv)
{
HINSTANCE a = NULL;
typedef bool (*GW)(char *buf, int len);
a = LoadLibrary(L"dllexample2");
static void (__cdecl *testfunc)(int) = NULL;
if( a == NULL )
{
cout << "dll not found" << endl;
system("Pause");
return 0;
}
GW GetWelcomeMessage = (GW)GetProcAddress(a, "GetWelcomeMessage");
if( GetWelcomeMessage == NULL )
{
cout << "testfunc == NULL" << endl;
system("Pause");
return 0;
}
char buf[128];
if(GetWelcomeMessage(buf, 128) == true) std::cout << buf;
system("Pause");
FreeLibrary(a);
return -100;
}
|
I think the problem was that my dll project was win32 console app
but it should be Win32 project
This is the thing what i changed...
Last edited on