cannot convert 'LPCWSTR {aka const wchar_t*}' to 'LPCSTR {aka const char*}
Change CreateWindowEx
to CreateWindowExW
or define the macro UNICODE
before including any headers.
cannot convert 'wchar_t*' to 'LPCSTR' {aka 'const char*'}
Well i see that pBuffer have some issues and thats propably becasue you are using multibyte character set i compiled this code with multibyte character set and i get same errors like you need to change multibyte character set to Use Unicode Character Set and it should solve your problem. Its viusal studio option :)
error C2440: '=': cannot convert from 'const char *' to 'LPCWSTR'
What you need to know about the windows API is that it comes in 2 flavors ,namely UNICODE flavor and non-UNICODE flavor.
When you include windows.h
the flavor selected depends on whether UNICODE is defined.
Many if not most WINAPI structures and function are just macros that basically just add either a W or an A to the macro-name to get the real name of the thing you want.
The UNICODE flavor requires character types of wchar_t
and non-UNICODE takes char
types (or pointers to them).
So you either must use the non-macro names for structs and/or functions or adjust your usage of types to the required macro-definition (in your case use std::wstring in stead of std::string).
Error C2664: MessageBoxW cannot convert argument 2 from 'const char ' to 'LPCWSTR'
std::runtime_error::what()
returns const char*
, so you should use MessageBoxA()
, not MessageBox()
nor MessageBoxW()
.
MessageBoxA(nullptr, error.what(), "An error has occured", MB_OK);
Also don't forget to remove the L
prefix from the string literal.
Related Topics
Createprocess Doesn't Pass Command Line Arguments
How to Call Derived Class Method from Base Class Pointer
How to Use Std::Imbue to Set the Locale for Std::Wcout
Std::Vector of Std::Vectors Contiguity
Member Fields, Order of Construction
Diamond Inheritance Lowest Base Class Constructor
Qt3D. Draw Transparent Qspheremesh Over Triangles
Finding "Dead Code" in a Large C++ Legacy Application
Reason for Using Non-Type Template Parameter Instead of Regular Parameter
Waiting Thread Until a Condition Has Been Occurred
Uses for Negative Zero Floating Point Value
Cast Vector<T> to Vector<Const T>
Cpu Dispatcher for Visual Studio for Avx and Sse
Why How to Call Base Template Class Method from Derived Class