var
Reg: TRegistry;
AppFileName: PChar;
begin
if Edit1.Text='' then // 判断文件名是否为空
begin
MessageBox(Handle,'应用程序名称不可以为空。','错误',MB_OK+MB_ICONERROR);
Exit;
end;
// 初始化AppFileName
GetMem(AppFileName,256);
Edit1.GetTextBuf(AppFileName,256);
Reg:=TRegistry.Create;
try
Reg.RootKey:=HKEY_LOCAL_MACHINE;
if (Reg.OpenKey('Software\Microsoft\Windows\CurrentVersion\Run',False))=True then
begin
// 在注册表中添加数值
Reg.WriteString('StartUp1',AppFileName);
end
else
MessageBox(Handle,'打开注册表失败。','错误',MB_OK+MB_ICONERROR);
finally
Reg.CloseKey;
Reg.Free;
FreeMem(AppFileName);
end;
Reg: TRegistry;
AppFileName: PChar;
begin
if Edit1.Text='' then // 判断文件名是否为空
begin
MessageBox(Handle,'应用程序名称不可以为空。','错误',MB_OK+MB_ICONERROR);
Exit;
end;
// 初始化AppFileName
GetMem(AppFileName,256);
Edit1.GetTextBuf(AppFileName,256);
Reg:=TRegistry.Create;
try
Reg.RootKey:=HKEY_LOCAL_MACHINE;
if (Reg.OpenKey('Software\Microsoft\Windows\CurrentVersion\Run',False))=True then
begin
// 在注册表中添加数值
Reg.WriteString('StartUp1',AppFileName);
end
else
MessageBox(Handle,'打开注册表失败。','错误',MB_OK+MB_ICONERROR);
finally
Reg.CloseKey;
Reg.Free;
FreeMem(AppFileName);
end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货