実行可能ファイルのパスです。 廃止; _get_pgmptr と _get_wpgmptrを使用します。
構文
extern char *_pgmptr;
extern wchar_t *_wpgmptr;
解説
コマンド インタープリター (Cmd.exe) からプログラムを実行すると、_pgmptr は実行可能ファイルの完全なパスに自動的に初期化されます。 たとえば、Hello.exeが C:\BIN にあり、C:\BIN がパスにある場合、 _pgmptr は次の実行時に C:\BIN\Hello.exe に設定されます。
C> hello
プログラムがコマンド ラインから実行されていない場合、 _pgmptr はプログラム名 (ファイル名拡張子のないファイルのベース名) またはファイル名、相対パス、または完全パスに初期化される可能性があります。
_wpgmptr は、ワイド文字版の _pgmptr で、wmain を使用するプログラムで使用されます。
汎用テキスト ルーチンのマップ
| Tchar.h のルーチン | _UNICODE と _MBCS が定義されていない |
_MBCS が定義されている |
_UNICODE が定義されている |
|---|---|---|---|
_tpgmptr |
_pgmptr |
_pgmptr |
_wpgmptr |
要件
| 変数 | 必須ヘッダー |
|---|---|
_pgmptr, _wpgmptr |
<stdlib.h> |
例
次のプログラムで、_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
}
%Fs を %Sに、main を wmain に変更することで、_wpgmptr を使用できます。