_pgmptr、_wpgmptr

実行可能ファイルのパスです。 非推奨。_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に、mainwmain に変更することで、_wpgmptr を使用できます。

関連項目

グローバル変数