KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q61262: argv

Article: Q61262
Product(s): See article
Version(s): 6.00   | 6.00
Operating System(s): MS-DOS | OS/2
Keyword(s): ENDUSER | | mspl13_c
Last Modified: 11-JUL-1990

If you use argv[0] in a program you have written, you may notice that
the string pointed to by argv[0] is different depending upon what
operating system/environment you are under. To access the full path
name of the program, use the global variable _pgmptr, which always
points to the full path, regardless of the environment you are in.
(For more information, query on the word _pgmptr.)

Under MS-DOS versions 3.x and later, argv[0] points to a string that
contains the complete path of the program being run. Under MS-DOS
versions 2.x, argv[0] contains the program name only. Under OS/2,
argv[0] generally points to a string that reflects exactly what was
entered to execute the program. The following are some exceptions to
the OS/2 rule:

1. OS/2 EXE linked with /PM:PM --

      argv[0] points to complete path of program.

2. OS/2 EXE under CodeView --

      argv[0] points to complete path of program.

These variations are not attributable to the C version 6.00 run-time
functions; they merely reflect what is passed to the program at run
time by the operating system.

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.