Share via


_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
}

若要使用 _wpgmptr,您可以將 %Fs 改為 %S,並將 main 改為 wmain

另請參閱

全域變數