Alright, so my simple DLL Hellow World function
#include "stdafx.h"
extern "C" void HelloWorld()
{
MessageBox( NULL, TEXT("Hello World"),
TEXT("In a DLL"), MB_OK);
}
isn’t getting called by my simple hello world app:
case IDM_ABOUT:
hinstDLL = LoadLibrary(L"phantasyhook.dll");
if (hinstDLL != NULL)
{
HelloWorld = (FARPROC) GetProcAddress(hinstDLL, "HelloWorld");
if (HelloWorld != NULL)
HelloWorld();
else
MessageBox(NULL, L"is null", L"dll Error", MB_OK);
FreeLibrary(hinstDLL);
}
break;
It opens the “is null” MessageBox, thought it should open up the Hello World one. What am I doing wrong?
You need to mark that a function should be exported by a DLL for other code to be able to load it. You can do by adding the __declspec(dllexport) or a module definition file.