views:

867

answers:

2

The only difference is that Winmain takes char* for lpCmdLine parameter, while wWinMain takes wchar_t*.

On Windows XP, if an application entry is WinMain, does Windows convert the command line from Unicode to Ansi and pass to the application?

If the command line parameter must be in Unicode (for example, Unicode file name, conversion will cause some characters missing), does that mean that I must use wWinMain as the entry function?

+4  A: 

On Windows XP, if an application entry is WinMain, does Windows convert the command line from Unicode to Ansi and pass to the application?

Yes.

If the command line parameter must be in Unicode (for example, Unicode file name, conversion will cause some characters missing), does that mean that I must use wWinMain as the entry function?

Yes, you should, if you want to correctly handle Unicode arguments to your program.

The documentation to WinMain() on MSDN also agrees.

You can, however, also use GetCommandLineW to retrieve the command line specifically in Unicode.

Joey
A: 

Windows XP upwards is unicode by default! And thus, no conversion is required. The C++ Runtime loader takes care of the argument passing to the application. Standard Win32 API dictates that the main entry is WinMain(...).

Hope this makes sense, Best regards, Tom

tommieb75
"Note that lpCmdLine uses the LPSTR data type instead of the LPTSTR data type. This means that WinMain cannot be used by Unicode programs." (http://msdn.microsoft.com/en-us/library/ms633559.aspx)
Joey
Thanks Johannes for the heads up and for reminding me.
tommieb75
Windows NT4 is Unicode by default :)
Paul Betts
Paul, to clarify- isn't XP unicode by default also!?!
tommieb75