[Windows programming] error: the parameter cannot be converted from "char *" to "lpcwstr"

Source: Internet
Author: User

Character Set problems. The Unicode character is larger than the ANSI memory usage. In the Win32 program, the standard definition char occupies one byte, and the Unicode version of char is defined as follows: typedef unsigned short wchar_t; occupies two bytes. Therefore, the function with characters as parameters also uses two versions.

Solution 1:

All functions with character parameters in the Wide-byte version should use the wide-byte version of the character parameter, it is easy to convert the string into a wide-byte: for example, to convert "application error" to the Unicode version, you only need to use a defined macro before it, such as l "application error" or text ("application error"). Therefore, you should set MessageBox (null, temp, "application error", mb_iconstop); changed to: MessageBox (null, temp, l "application error", mb_iconstop );

Solution 2:

Set vs project --> properties --> Configuration properties --> General --> character set --> using multi-Byte Character Set

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.