_pgmptr, _wpgmptr
可执行文件的路径。 已否决;使用 _get_pgmptr 和 _get_wpgmptr。
extern char *_pgmptr;
extern wchar_t *_wpgmptr;
备注
当程序 orders 解释器 (Cmd.exe) 运行, _pgmptr 自动初始化为可执行文件的完整路径。 例如,因此,如果 Hello.exe 在 C: \BIN and 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 使用 _wpgmptr 到 wmain。