For those
interested in the
Windows API, for a non-
console program, the entry point is
WinMain. (Win32 Console programs still get the main()
prototyping scheme to determine their
entry point).
WinMain's prototype looks something like this:
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
Now the third parameter (LPSTR is really just
Hungarian Notation for char*) is where you get your
command line as a
string (you do not get the free tokenization here). The problem here is that the string that you
receive is
single-byte (the same as you would in
argv,
argc), and oftentimes you will need a
Unicode string (for localized apps, etc).
To get the
Unicode command line, you could have to call:
LPWSTR wargv = CommandLineToArgvW(GetCommandLine(), *nArgs);
This will get the Unicode command line as a
TCHAR string, and dump it into
CommandLineToArgvW to get a similar result to the standard argv, argc combination. According to the C/C++
standard, command-line strings (argv) are not
Unicode, and this is the solution
Microsoft put forth. The new wargv string is a
double-byte character string, and is suitable for all versions of an application. (Command lines are still very important to
Win32 executables, as they tell the program in what mode to run in, as determined by the
individual app).