INF: argvIs Dependent on the Operating System

ID Number: Q61262

5.10 6.00 6.00a 6.00ax 7.00 | 5.10 6.00 6.00a

MS-DOS | OS/2

Summary:

In Microsoft C versions 5.0, 5.1, 6.0, 6.0a, 6.0ax, and C/C++ version

7.0 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 on whether

or not your application was bound.

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.)

More Information:

Because MS-DOS provides no information about the command line to a

program, the C startup code for MS-DOS applications passes the full

path in arg[0].

Under OS/2, argv[0] generally points to a string that reflects exactly

what was entered to run the program. This information is provided by

OS/2 itself. 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.

For a bound application running under MS-DOS, only the program name is

passed in arg[0] because the bound application is using the OS/2

startup code. The OS/2 startup code tests to see whether the

information was not passed (that is, it is running under MS-DOS) and

will provide only the program name if this is the case.

These variations are not attributable to the C version 6.0 run-time

functions; they merely reflect what is passed to the program at run

time by the operating system.

Additional reference words: 5.00 5.10 6.00 6.00a 6.00ax 7.00