We have to implement shell32!RegenerateUserEnvironment function to improve compatibility.
Every process has an environment block that contains a set of environment variables and their values. There are two types of environment variables: user environment variables (set for each user) and system environment variables (set for everyone).
Each environment block contains the environment variables in the following format:
If the system environment variables were changed, then WM_SETTINGCHANGE message will be notified to each windows. When Explorer receives WM_SETTINGCHANGE, Explorer calls shell32!RegenerateUserEnvironment to reload its environment variables.
The 1st argument of RegenerateUserEnvironment function is a pointer to a Unicode environment block. If the 2nd argument bUpdateSelf was TRUE, then the environment of the current process will be also reloaded.
RegenerateUserEnvironment updates the return value of GetEnvironmentStrings function. The return value of GetEnvironmentStrings is an ANSI environment block.
I created a test program: EnvTest.zip