BOOL SetEnvironmentVariable( LPCTSTR lpName, // environment variable name LPCTSTR lpValue // new value for variable);
DWORD GetEnvironmentVariable( LPCTSTR lpName, // environment variable name LPTSTR lpBuffer, // buffer for variable value DWORD nSize // size of buffer);
注:
(1)子进程会继承父进程的环境变量,即,当父进程中设置了环境变量e而子进程中没有设置的时候,子进程同样可以获取e,只不过值与父进程的e是一样的。
(2)子进程和父进程拥有相同的环境变量时,各自独立,即不管哪个进程设置e,都不会影响其它进程e的值