다음을 통해 공유


_pgmptr, _wpgmptr

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at _pgmptr, _wpgmptr.

The path of the executable file. Deprecated; use _get_pgmptr and _get_wpgmptr.

Syntax

extern char *_pgmptr;  
extern wchar_t *_wpgmptr;  

Remarks

When a program is run from the command interpreter (Cmd.exe), _pgmptr is automatically initialized to the full path of the executable file. For example, if Hello.exe is in C:\BIN and C:\BIN is in the path, _pgmptr is set to C:\BIN\Hello.exe when you execute:

C> hello   

When a program is not run from the command line, _pgmptr might be initialized to the program name (the file's base name without the file name extension) or to a file name, relative path, or full path.

_wpgmptr is the wide-character counterpart of _pgmptr for use with programs that use wmain.

Generic-Text Routine Mappings

Tchar.h routine _UNICODE and _MBCS not defined _MBCS defined _UNICODE defined
_tpgmptr _pgmptr _pgmptr _wpgmptr

Requirements

Variable Required header
_pgmptr, _wpgmptr <stdlib.h>

Example

The following program demonstrates the use of _pgmptr.

// crt_pgmptr.c  
// compile with: /W3  
// The following program demonstrates the use of _pgmptr.  
//  
#include <stdio.h>  
#include <stdlib.h>  
int main( void )  
{  
   printf("The full path of the executing program is : %Fs\n",   
     _pgmptr); // C4996  
   // Note: _pgmptr is deprecated; use _get_pgmptr instead  
}  

You could use _wpgmptr by changing %Fs to %S and main to wmain.

See Also

Global Variables