CreateMutex () Parameter problem

Source: Internet
Author: User

Example: Hmutex = CreateMutex (NULL, FALSE, "screen");

Error C2664: "CREATEMUTEXW": Cannot convert parameter 3 from "const char [7]" to "LPCWSTR"

Not related to the type that is pointed to, conversion requires reinterpret_cast, C-style conversion, or function-style conversion;

Workaround: The ASCII environment calls the Createmutexa,unciode environment call CREATEMUTEXW

The reason for this example is that the Unicode environment is used, the function automatically calls the CREATEMUTEXW wide character function, so the parameter LPCTSTR is LPCWSTR type, plus _t (), TEXT (), or L (character) Hmutex = CreateMutex (NULL, false,_t ("screen")), or Hmutex = CreateMutex (null, false,l "screen"); or Hmutex = CreateMutex (NULL, False,text ("screen"));

CreateMutex () Parameter problem

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.