在delphi中如何编辑开机启动
1个回答
展开全部
方法有很多,可以写入注册表,例如:
var
FileName, FilePath: string;
Reg: Tregistry;
begin
FileName := ExtractFileName(application.ExeName); //开机启动的执行程序名
FilePath := application.ExeName; //完整路径
Reg := Tregistry.Create;
try
Reg.Rootkey := HKEY_LOCAL_MACHINE;
Reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\Run', true);
Reg.WriteString(FileName, FilePath) //添加注册表项和键值
Reg.CloseKey; //关闭注册表
finally
Reg.Free;
end;
end;
var
FileName, FilePath: string;
Reg: Tregistry;
begin
FileName := ExtractFileName(application.ExeName); //开机启动的执行程序名
FilePath := application.ExeName; //完整路径
Reg := Tregistry.Create;
try
Reg.Rootkey := HKEY_LOCAL_MACHINE;
Reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\Run', true);
Reg.WriteString(FileName, FilePath) //添加注册表项和键值
Reg.CloseKey; //关闭注册表
finally
Reg.Free;
end;
end;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询