如何获取默认的%temp%值 [英] how to get default %temp% value

查看:168
本文介绍了如何获取默认的%temp%值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在尝试使用ExpandEnvironmentString获取WINDOWS%TEMP%的值.但可以重新定义.
如何获取默认的%temp%值?

Hello all,

i''m trying to get windoes %temp% value using ExpandEnvironmentString. but it can be redefined.
how to retrieve default %temp% value?

推荐答案

默认值是什么意思?
运行程序之前的值?
你不知道.
您将需要运行以Windows开头的程序并进行记录.

我认为您必须像 Madhu 所说的那样使用GetTempPath.

这是根据文档返回的内容-
GetTempPath函数按以下顺序检查环境变量是否存在,并使用找到的第一个路径:
1. TMP环境变量指定的路径.
2. TEMP环境变量指定的路径.
3. USERPROFILE环境变量指定的路径.
4. Windows目录.
请注意,该函数不会验证路径是否存在.
符号链接行为-如果路径指向符号链接,则临时路径名称将保留所有符号链接.
What do you mean by default value?
The value that was before your program was run?
You cannot know it.
You will need to run a program that starts with Windows and record it.

I think you must use GetTempPath as Madhu said.

Here is what it returns according to the documentation -
The GetTempPath function checks for the existence of environment variables in the following order and uses the first path found:
1. The path specified by the TMP environment variable.
2. The path specified by the TEMP environment variable.
3. The path specified by the USERPROFILE environment variable.
4. The Windows directory.
Note that the function does not verify that the path exists.
Symbolic link behavior—If the path points to a symbolic link, the temp path name maintains any symbolic links.


查看注册表项 HKEY_CURRENT_USER \ Environment ,并检查TMP和TEMP的值.如果这些值不存在,那么您将无法确定原始格式.
Look at the registry key HKEY_CURRENT_USER\Environment, and check the value of TMP and TEMP. If these values do not exist then you cannot be sure what the originals were.


使用API​​ ^ ]
Use API GetTempPath[^]


这篇关于如何获取默认的%temp%值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆