windows_programming_notes.nbk: Home | Index | Next Page: GetDateFormat | Previous Page: GetClientRect


 GetCommandLine

The GetCommandLine function retrieves the command-line string for the current process.

    LPTSTR GetCommandLine(VOID);

Parameters

This function has no parameters.

Return Values

The return value is a pointer to the command-line string for the current process.

Remarks

ANSI console processes written in C can use the argc and argv arguments of the main function to access the command-line arguments. ANSI GUI applications can use the lpCmdLine parameter of the WinMain function to access the command-line string, excluding the program name. The reason that main and WinMain cannot return Unicode strings is that argc, argv, and lpCmdLine use the LPSTR data type for parameters, not the LPTSTR data type. The GetCommandLine function can be used to access Unicode strings, because it uses the LPTSTR data type.

To convert the command line to an argv style array of strings, call the CommandLineToArgvW function.

Note

The name of the executable in the command line that the operating system provides to a process is not necessarily identical to that in the command line that the calling process gives to the CreateProcess function. The operating system may prepend a fully qualified path to an executable name that is provided without a fully qualified path.

Requirements


windows_programming_notes.nbk: Home | Index | Next Page: GetDateFormat | Previous Page: GetClientRect


Notebook exported on Monday, 7 July 2008, 18:56:50 PM Eastern Daylight Time