Reputation: 2304
I have one line in my C++ program
HINSTANCE hInstLibrary = LoadLibrary("DLL_tut.dll");
Here I'm getting error saying that error C2664: 'LoadLibraryW' : cannot convert parameter 1 from 'const char [12]' to 'LPCWSTR'
I'm trying to implement program given in link http://www.codeguru.com/cpp/cpp/cpp_mfc/tutorials/article.php/c9855/DLL-Tutorial-For-Beginners.htm
Tried finding some solutions and found this one closest Incompatible var types I think, but I'm not understanding that how to covert that string of file, the last answer this question is more appropriate I guess. Can someone suggest how to remove this error ?
PS: not some homework, new to dlls and trying to understand by myself. stuck in this one last step.
Upvotes: 2
Views: 585
Reputation: 1638
Try
HINSTANCE hInstLibrary = LoadLibrary(L"DLL_tut.dll");
or
HINSTANCE hInstLibrary = LoadLibrary(_TEXT("DLL_tut.dll"));
The thing is that your project is probably compiled with UNICODE macro defined, which causes LoadLibrary to use LoadLibraryW version, which requires Unicode string as a parameter.
Upvotes: 2