Today in the project encountered a small problem, in the call to other people dynamic Connection library (DLL), always appear the following prompt, causing the program does not work properly, programming environment: VS2010+MFC
Issue tip:error C2664: "Loadlibraryw": Cannot convert parameter 1 from "const char *" to "LPCWSTR"
After finding the material, the problem is solved, thanks:
Solution from: http://blog.sina.com.cn/s/blog_6a2236590100xbgl.html
1 Static Call Lib
Project | Setting
Link Tab Library Modules office
Add "XXX.lib"
Then include "XXX.h"
Put XXX.lib (inbound file), XXX.DLL (Dynamic library file)
XXX.h (header file)
Put them all in the project directory.
Method Two:
pragma commet (lib, "*****.lib")
2 Dynamic Call DLL
Pass
LoadLibrary
GetProcAddress
FreeLibrary implementation.
Cause: The project supports only Unicode characters
Workaround:
1, project properties, configuration Properties--General---> Character set----> use multibyte Character set
2, that is, the wide character, so the following line of code, should be compiled with errors Hinst=loadlibrary ("InTheHand.Net.Personal.dll"); That is Cannot convert parameter 1 from ' char [+] ' to ' const unsignedshort * ' Landlord will change the code to: Hinst=loadlibrary (L "InTheHand.Net.Personal.dll"); Or Hinst=loadlibrary (_t ("InTheHand.Net.Personal.dll")); Give it a try 。 |
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
MFC Call DLL Problem: Error C2664: "Loadlibraryw": Cannot convert parameter 1 from "const char *" to "LPCWSTR