In the Windows System Properties | Environment Variables, there is a variable "AppStatus=status1"
.
There is an exe named MyApp.exe. In the implementation it changes the variable with the code.
int ret = putenv("AppStatus=status2"); // Change the environment variable.
If use API char * pStatus = getenv("AppStatus");
, the returned value is "status2"
.
What I want to get is the original value defined in the OS ("AppStatus=status1"
) not in the process block. To implement this I can query the registry key
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\Path.
But it should be better if there is an API that supports it. Is anybody aware of it?