onlyou13

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
procedure AddWindowsAutoRun;
var
  Reg: TRegistry;
begin
  Reg := TRegistry.Create(KEY_WRITE);
  try
    Reg.RootKey := HKEY_LOCAL_MACHINE;
    Reg.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Run', True);
    Reg.WriteString('xxx', Application.ExeName);
    Reg.CloseKey;
  finally
    Reg.Free;
  end;
end;

procedure DelWindowsAutoRun;
var
  Reg: TRegistry;
begin
  Reg := TRegistry.Create(KEY_WRITE);
  try
    Reg.RootKey := HKEY_LOCAL_MACHINE;
    if Reg.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Run', False) then
      Reg.DeleteValue('xxx');
    Reg.CloseKey;
  finally
    Reg.Free;
  end;
end;

 

posted on 2020-03-07 16:35  onlyou13  阅读(100)  评论(0编辑  收藏  举报