Windows with Delphi Windows API (94) Windows Filesystem (41) Windows Forms (69) Windows Graphics (38)
Exchange Links About this site Links to us 
|
How to modify the PATH variable
This article has not been rated yet. After reading, feel free to leave comments and rate it.
Use the following simple function ..
E.g. like this:
SetSystemEnvironmentVariable ('PATH', 'c:\windows;c:\programs\myapp');
 | |  | | procedure SetSystemEnvironmentVariable (const name, value : string);
var
rv : DWORD;
begin
with TRegistry.Create do
try
RootKey := HKEY_LOCAL_MACHINE;
OpenKey ('SYSTEM\CurrentControlSet\Control\SessionManager\Environment', False);
WriteExpandString (name, value);
SendMessageTimeout (HWND_BROADCAST, WM_SETTINGCHANGE, 0,
LParam (PChar ('Environment')),
SMTO_ABORTIFHUNG, 5000, rv);
finally
Free
end
end; | |  | |  | You don't like the formatting? Check out SourceCoder then!
Comments:
|