Hi.
My application does some changes in the systems PATH variable using code show below, then i call BroadCastChanges. All seems to work fine. THe newly added path can be accessed from anywhere, but...
Ping, WinHlp32 etc. cannot be accessed.
It seems like the %system% variables are placed out of order.
Has anyone a solution?
Change PATH:
Broadcast Changes:
//Nordlund
My application does some changes in the systems PATH variable using code show below, then i call BroadCastChanges. All seems to work fine. THe newly added path can be accessed from anywhere, but...
Ping, WinHlp32 etc. cannot be accessed.
It seems like the %system% variables are placed out of order.
Has anyone a solution?
Change PATH:
Code:
with TRegistry.Create do
try
RootKey := HKEY_LOCAL_MACHINE;
if OpenKey('SYSTEM\CurrentControlSet\Control\Session Manager\Environment\', False) then
begin
if ValueExists('Path') then
begin
s := ReadString('Path');
WriteString('Path', s+';'+MyNewDir);
end;
end;
finally
CloseKey;
Free;
end;
Broadcast Changes:
Code:
procedure BroadcastChange;
var
lParam, wParam :Integer;
Buf: Array[0..10] of Char;
aResult : Cardinal;
begin
Buf := 'Environment';
wParam := 0;
lParam := Integer(@Buf[0]);
SendMessageTimeout(HWND_BROADCAST,
WM_SETTINGCHANGE,
wParam,
lParam,
SMTO_NORMAL,
4000,
aResult);
if aResult <> 0 then
SysErrorMessage(aResult);
end;
//Nordlund