开发者

TEMP Environment variable expansion for C++ (Windows)

I need to get a %TEMP% environmental variable value string in Windows platform.

If I try to use any methods(C / C++) (getenv(), …) to get this environmental variable, it returns with “~” in that string.

For Example: C:\DOCUME~1\pkp\LOCALS~1\Temp.

But I need to get full string for some reasons, as below:

C:\Documents and Settings\pkp\Local Settings\Temp

If anyone knows any methodology to 开发者_JAVA技巧obtain this, please let me know.


Call GetLongPathName() on the short name.


DOCUME~1 is not an environment variable. It is a legacy naming convention from DOS still supported by windows for backward compatibility. Hence there is nothing to 'expand' in the environment variable sense.


You can use GetTempPath it obliges you to include "windows.h" but I assume you how to do that anyway since you're writing a windows app.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜