The most important part is to understand the error; know what is a const char [4]
, is the easy part but, what about the LPCTSTR
?
According to the Microsoft documentation:
An LPCWSTR
if UNICODE is defined, an LPCSTR
otherwise. For more
information, see Windows Data Types for Strings.
And the LPCWSTR
is:
A pointer to a constant null-terminated string of 16-bit Unicode characters. For more information, see Character Sets Used By Fonts.
First, you must check out what type of encoding are using your program; it seems that you're using UNICODE
, so in the end you're trying to convert a const pointer to char
s (the "OFF" constant) to a const pointer to wchar_t
, and (logically) the conversion isn't allowed.
Then, you can choose the correct string type; if UNICODE is defined, your #define
must be wide string:
// Note the L
#define METHOD_ONE L"OFF"
You can also define it this way:
#ifdef UNICODE
#define METHOD_ONE L"OFF"
#else
#define METHOD_ONE "OFF"
#endif
Or use the _T
macro suggested by Roman R. The only that this macro does is to append L
prefix to the text:
#ifdef UNICODE
#define _T(x) L ##x
#else
#define _T(x) x
#endif
In the end, you must be aware of what kind of string are using; but Microsoft is hidding it by using an obscure chain of #define
s and typedef
s.