Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GetEnvironmentStrings and stange values "=::=::\" [duplicate]

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?

Here is the code :

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
...

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

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

like image 616
unixstudio Avatar asked May 03 '12 12:05

unixstudio


1 Answers

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.

like image 63
Ryan Avatar answered Nov 13 '22 18:11

Ryan