ALIBPath, AINCPath: string);
resourcestring
  REG_C51_LIB = 'C51LIB';
  REG_C51_INC 
= 'C51INC';
  REG_PATH 
= 'PATH';
  REG_MACHINE_LOCATION 
= 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment';
  REG_USER_LOCATION 
= 'Environment';
var
  FPath: string;
  
function DataExits(const ASources, AData: string): Boolean;
var
  FList: TStrings;
  i: Integer;
begin
  Result :
= False;
  FList :
= Split(ASources, ';');
  
for i := 0 to FList.Count - 1 do
  
begin
    
if FList[i] = AData then Result := True;
  
end;
end;
begin
  
with TRegistry.Create do
  
begin
    try
      RootKey :
= HKEY_LOCAL_MACHINE;
      OpenKey(REG_MACHINE_LOCATION, True);

      FPath :
= ReadString(REG_PATH);

      
if not DataExits(FPath, ALIBPath)then
      
begin
        FPath :
= ReadString(REG_PATH) + ALIBPath + ';';

        WriteString(REG_PATH, FPath);
        SetEnvironmentVariable(PChar(REG_C51_LIB), PChar(ALIBPath));
//        SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, Integer(PChar('Environment')));
      
end;

      FPath :
= ReadString(REG_PATH);
      
if not DataExits(FPath, AINCPath)then
      
begin
        FPath :
= ReadString(REG_PATH) + AINCPath + ';';

        WriteString(REG_PATH, FPath);
        SetEnvironmentVariable(PChar(REG_C51_LIB), PChar(ALIBPath));
//        SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, Integer(PChar('Environment')));
      
end;
      SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 
0, Integer(PChar('Environment')));
    finally
      Free;
    
end;
  
end;
end;

相关文章:

  • 2022-12-23
  • 2021-06-28
  • 2022-12-23
  • 2021-12-27
  • 2021-12-09
  • 2022-02-10
  • 2021-10-14
  • 2021-05-29
猜你喜欢
  • 2022-12-23
  • 2021-10-28
  • 2022-01-20
  • 2021-11-21
  • 2022-12-23
相关资源
相似解决方案