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;