Reg.RootKey := HKEY_LOCAL_MACHINE;
KeyName := 'SYSTEM/CurrentControlSet/Control/Session Manager/Environment/';
If Reg.OpenKey(KeyName, false) Then Reg.WriteExpandString('环境变量名称','环境变量值');
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, LParam(PChar('Environment')), SMTO_ABORTIFHUNG, 5000, RV);