What am I doing wrong? Typedef declaration maybe? Is there any similar working sample for Visual C++?
Here is the code:
Code: Select all
typedef void (__stdcall * LPFNEXPORTEDPREDICATE)(void);
void CMFCApplication3View::OnBnClickedLoadPrologDll()
{
HMODULE hMod = 0x0000;
wchar_t wszDLLPath[256];
char szFunctionName[100];
LPFNEXPORTEDPREDICATE lpfnExportedPredicate = NULL;
memset(wszDLLPath, 0, sizeof(wszDLLPath));
wcscpy(wszDLLPath, _T("libProlog.dll"));
strcpy(szFunctionName, "exportedPredicate");
hMod = LoadLibrary(wszDLLPath);
if (hMod)
{
lpfnExportedPredicate = (LPFNEXPORTEDPREDICATE)GetProcAddress(hMod, (LPCSTR)szFunctionName);
if (lpfnExportedPredicate)
{
lpfnExportedPredicate(); //Crashes here
}
FreeLibrary(hMod);
}
}