This article was previously published under Q126571
This article has been archived. It is offered "as is" and will no longer be updated.
MS-DOS applications written in C generally use main() for the entry point. The command line can be obtained from the argv parameter of main(). In particular, the program name is pointed to by argv.
There is a similar mechanism that can be used from Windows-based and Win32-based applications.
Windows-based and Win32-based application use WinMain() as the entry point. WinMain() has the lpszCmdLine parameter for the command line arguments, but this parameter does not include the program name. However, you can still get to the program name through the variable __argv.
In a 32-bit application you can just reference __argv directly. It is declared in stdlib.h
In a 16-bit application, __argv is not declared and you will need to declare it. Include the following declaration in your source or header file.