What I want to do is to put DLLname where DLLnameHERE.dll is.
This is a piece of my code:
int ToLoadLibrary(char * DLLname)
{
HINSTANCE hinstLib;
MYPROC ProcAdd;
BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;
// Get a handle to our DLL module created in the previous example. Make sure you already copied the mydllpro.lib and mydllpro.dll to the appropriate folders...
hinstLib = LoadLibrary(L"DLLnameHERE.dll");
Thanks in advance.
The problem you run into is a Microsoft-specific one. The macro LoadLibrary
expands, depending on preprocessor macros, either to the name of a function that accepts a char const*
or a wchar_t const *
. In your case, the call
hinstLib = LoadLibrary(L"DLLnameHERE.dll");
suggests that the latter is the case.
The easiest way around this problem is to use the name of the function that accepts char const *
directly; it is LoadLibraryA
:
hinstLib = LoadLibraryA(DLLname);
The mechanism is described in greater detail here in the MSDN.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments