This is how you do it in NT….
[code lang=”delphi”]procedure SetSystemEnvironmentVariable (const name, value : string);
var
rv : DWORD;
begin
with TRegistry.Create do
try
RootKey := HKEY_LOCAL_MACHINE;
OpenKey (‘SYSTEM\CurrentControlSet\Control\Session
Manager\Environment’, False);
WriteExpandString (name, value);
SendMessageTimeout (HWND_BROADCAST, WM_SETTINGCHANGE, 0, LParam (PChar (‘Environment’)), SMTO_ABORTIFHUNG, 5000, rv);
finally
Free
end
end;[/code]
[tags]Delphi, API[/tags]
0 Kommentare zu “Newsflash Environment: SetSystemEnvironmentVariable”