This is a long pointer to a constant, a wide string (i.e. a string with wide characters).
Since this is a wide line, you want your constant to look like this: L"TestWindow" . I would also not create an intermediate a , I would just pass L"TestWindow" for the parameter:
ghTest = FindWindowEx(NULL, NULL, NULL, L"TestWindow");
If you want to be pedantically correct, βLPCTSTRβ is a βtextβ string β a wide string in the Unicode assembly and a narrow string in the ANSI assembly, so you should use the appropriate macro:
ghTest = FindWindow(NULL, NULL, NULL, _T("TestWindow"));
Few people care about creating code that can compile for both Unicode character sets and ANSI, and if you don't get it really right, there can be quite a bit of extra work for a small gain. In this particular case, there is not much extra work, but if you are manipulating strings, there is a whole set of string manipulation macros that allow the correct functions.
Jerry Coffin Feb 09 2018-10-09 16:49
source share