Advertisement

Argc and Argv

Started by July 31, 2000 02:37 AM
3 comments, last by DreadNosh 24 years, 4 months ago
Heya. I''m new to windows development and am wondering how to go about getting "command line" parameters from Windows. Normally I just grab the Argc and Argv parameters passed into the Main function, but what is the equivalent in windows? Thanks
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, char *szCmdLine, int nCmdShow);

The 3rd argument of the WinMain function should hold the command line.
==========================================In a team, you either lead, follow or GET OUT OF THE WAY.
Advertisement
Windows NT (and 2000), CE, and all future flavors of Windows (beyond Windows Me) use the Unicode character set which uses 2 bytes for each character in a string. While you _can_ use that third parameter in WinMain, that will only work on Windows 95, 98, and Me because they use 8 bits per character. The portable (and recommended) way to get the command line and its arguments is the API function GetCommandLine.
Try this undocumented macro in windows..


__argc, __argv
NT uses Unicode internally but the API can speak either Unicode or not. It''s also possible to get "WinMain" in Unicode flavors, check MSDN for stuff about "wWinMain" or even "_tWinMain"

I vaguelly recall some that there exists some Win32 platform that is Unicode only but I don''t remember what it is. It''s not NT.

-Mike

This topic is closed to new replies.

Advertisement