MFC Call DLL Problem: Error C2664: "Loadlibraryw": Cannot convert parameter 1 from "const char *" to "LPCWSTR

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.