这些奇怪的环境变量是什么? [英] What are these strange environment variables?

查看:114
本文介绍了这些奇怪的环境变量是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 GetEnvironmentString()来获取程序的环境变量。

I use GetEnvironmentString() to get the program's environment variables.

每个程序都有这样的结果首先:

Every program has such result in the first:

=::=::\

我不知道这是什么意思?

I don't know what does it mean?

这是代码:

LPWCH lpEnvString=GetEnvironmentStringsW();
 LPWSTR lpszVariable=(LPWSTR)lpEnvString;
 while (*lpszVariable)
 {
     wprintf(L"%s\n",lpszVariable);
     lpszVariable+=wcslen(lpszVariable)+1;
 }
 FreeEnvironmentStringsW(lpEnvString);

如果我们开始列出这些变量,我们会看到如下所示的东西:

Also if we start listing such variables we would see stuff like:

=::=::\
=C:=C:\Users\username\value
=ExitCode=00000001
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\artik\AppData\Roaming
CommonProgramFiles=C:\Program Files (x86)\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
...

另一方面, getenv(= ExitCode) getenv(= C:)返回NULL。

On the other hand, getenv("=ExitCode") or getenv("=C:") returns NULL.

您可以提供适当的文档 ,
例如 getenv()忽略这样的字符串以及如何处理这些值?

Can you provide a proper documentation of this "feature", for example getenv() ignores such strings and how such values should be treated?

推荐答案

他们是从cmd.exe中扫描出来,用于处理ms-dos目录,他们基本上没有什么用处,而且比任何东西更古老。本质上,它跟踪每个驱动器当前目录,并保持为一个环境变量,以轻松传递给其他进程。

They are leftovers from cmd.exe emulating ms-dos directory handling, they basically have little use, and are more archaic than anything. Essentially, it keeps track of a per drive current directory, and is kept as an environment variable to pass to other processes with ease.

这篇关于这些奇怪的环境变量是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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