Reputation: 41002
how can i make sure that when i transfer Minesweeper it will be in unicode and not will be casted to ASCII?
HWND procHnd;
HWND windowHnd=FindWindow(NULL,"Minesweeper");
does it matter at all the name of the process or window representation?
Upvotes: 0
Views: 683
Reputation: 613252
You can explicitly use the Unicode version of the API
HWND windowHnd = FindWindowW(NULL, L"Minesweeper");
You are currently building your application for ANSI characters. If you want to use Unicode throughout you should change your project options to use Unicode. If you did that you can simply write it as
HWND windowHnd = FindWindow(NULL, L"Minesweeper");
Windows API functions that have parameters which contain text are available in two versions, an ANSI version and a Unicode version. For example the user32 DLL does not export a function called FindWindow
. Instead it exports FindWindowA
, the ANSI version, and FindWindowW
, the Unicode version. Macros in the Windows header files convert FindWindow
into either FindWindowA
or FindWindowW
, depending on which character set you target.
In Visual Studio you can set this option in the project configuration under Configuration Properties | General | Character Set. Select Use Unicode Character Set.
Upvotes: 1