Probably a pretty newbie question but I'm having a hard time how to correctly use GetProcAddress to gain access to a function in a DLL I wrote...
The following is in the a.dll file I created (the function I wish to expose):
A.cpp
A.h
Now, in my actual application I am trying to load the dll function DoWork as follows:
But this code doesn't compile, I get the following error:
error C2440: 'initializing' : cannot convert from 'int (__stdcall *)(void)' to 'int (__cdecl *)(const char *)'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
At this point its a litte hit-and-miss, I'm doing some reading and searching on how to properly use GetProcAddress() but I can't find examples that illustrate using it in the context I am trying to ...
Any help, ideas, or hints would be greatly appreciated...
Thanks,
The following is in the a.dll file I created (the function I wish to expose):
A.cpp
Code:
BOOL DoWork (LPCTSTR a, DWORD b = 5000, BOOL c = TRUE, UCHAR d = 10, UCHAR e = 0)
A.h
Code:
A_DLLPORT BOOL DoWork (LPCTSTR a, DWORD b, BOOL c, UCHAR d, UCHAR e);
Now, in my actual application I am trying to load the dll function DoWork as follows:
Code:
HMODULE hModule = LoadLibrary ("a.DLL");
if (!hModule)
{
return;
}
BOOL (*DoWork) (LPCTSTR) = GetProcAddress (hModule, "DoWork");
if (!DoWork)
{
FreeLibrary (hModule);
return;
}
if (DoWork(something))
{
// do something //
}
FreeLibrary (hModule);
But this code doesn't compile, I get the following error:
error C2440: 'initializing' : cannot convert from 'int (__stdcall *)(void)' to 'int (__cdecl *)(const char *)'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
At this point its a litte hit-and-miss, I'm doing some reading and searching on how to properly use GetProcAddress() but I can't find examples that illustrate using it in the context I am trying to ...
Any help, ideas, or hints would be greatly appreciated...
Thanks,