Command Prompt for Windows




argpath, _wargpath, _targpath

char *argpath(int index);
wchar_t *_wargpath(int index);
TCHAR *_targpath(int index);

Retrieve a command line argument index and convert it to a full path name.

Parameter Description
index Specifies which argument to retrieve. Specifying an index of 0 retrieves the current directory, as a full path name. Command line arguments start from an index of 1.

Returns

On success it returns a the address of a NULL terminated string containing the full path name. On error it returns a NULL.

Comments

The full path name is stored in a static buffer and is over-written each time this function is called.

Full path names are made up of the following components :-

drive:\directory\filename

Component When not Specified
drive Current drive is used.
directory Current directory is used. Also relative directories are converted to absolute directories.
filename *.* is used. Wildcard characters are allowed in the filename.

See Also

argc, argv, argabs

Examples

The following examples assume the current directory is C:\WINDOWS :-

Argument Full path
C: C:\WINDOWS\*.*
C:\ C:\*.*
\DOS\ C:\DOS\*.*
NOTEPAD.EXE C:\WINDOWS\NOTEPAD.EXE
*.EXE C:\WINDOWS\*.EXE
WHAT C:\WINDOWS\WHAT.
*.* C:\WINDOWS\*.*
. C:\WINDOWS\*.*
.. C:\*.*