procedure SetAutoRun(Auto:Boolean);
var
Reg: TRegistry;
begin
// 初始化AppFileName
Reg:=TRegistry.Create;
try
Reg.RootKey:=HKEY_LOCAL_MACHINE;
if (Reg.OpenKey('Software/Microsoft/Windows/CurrentVersion/Run',False))=True then
begin
// 在注册表中添加数值
if Auto then
Reg.WriteString('descript',Application.ExeName)
else
Reg.DeleteValue('descript');
end
else
ShowMessage('打开注册表失败。');
finally
Reg.CloseKey;
Reg.Free;
end;
end;