You can work with two types of entry-point functions in WinAPI: WinMain
and wWinMain
.
The WinMain
function is identical to wWinMain
, except the command-line arguments are passed as an ANSI string. The Unicode version is preferred.
Source: Microsoft Docs
Both should work well with Microsoft Visual C++ compiler. However, there are some problems with MinGW and wWinMain
function.
Solution 1: Use Microsoft Visual C++ compiler.
Solution 2: Use MinGW and change your entry-point function to WinMain
because it works correctly on MinGW (also change PWSTR pCmdLine
to PSTR pCmdLine
):
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, PSTR pCmdLine, int nCmdShow)
^^^^^^^ ^^^^
Solution 3: It is discussed here but I didn't test it.
If you are using MinGW-w64, you can add
-municode
as your command line option. Your original source code should be compiled correctly.