unit Unit1;
interface
uses
Windows , Messages , SysUtils , Variants , Classes , Graphics , Controls , Forms ,
Dialogs , registry , StdCtrls;
type
TForm1 = class (TForm)
Button1 : TButton; // 用于控制程序的运行
Edit1 : TEdit; // 用于记录用户要添加的数值名称
Edit2 : TEdit; // 用于记录数值数据(即自启动程序的路径)
StaticText1 : TStaticText;
procedure Button1Click(Sender : TObject);
private
{ Private declarations }
public
{ Public declarations }
end ;
var
Form1 : TForm1;
implementation
{ $R *. dfm}
procedure TForm1 . Button1Click(Sender : TObject);
var
Reg:TRegistry;
begin
Reg:=TRegistry.Create; //创建一个新键
Reg.RootKey:=HKEY_LOCAL_MACHINE; //将根键设置为HKEY_LOCAL_MACHINE
Reg.OpenKey('SOFTWARE\Microsoft\windows\CurrentVersion\Run',true);//打开一个键
Reg.WriteString('TimeHint',Application.ExeName); //在Reg这个键中写入数据名称和数据数值
Reg.CloseKey;
end;
end.
interface
uses
Windows , Messages , SysUtils , Variants , Classes , Graphics , Controls , Forms ,
Dialogs , registry , StdCtrls;
type
TForm1 = class (TForm)
Button1 : TButton; // 用于控制程序的运行
Edit1 : TEdit; // 用于记录用户要添加的数值名称
Edit2 : TEdit; // 用于记录数值数据(即自启动程序的路径)
StaticText1 : TStaticText;
procedure Button1Click(Sender : TObject);
private
{ Private declarations }
public
{ Public declarations }
end ;
var
Form1 : TForm1;
implementation
{ $R *. dfm}
procedure TForm1 . Button1Click(Sender : TObject);
var
Reg:TRegistry;
begin
Reg:=TRegistry.Create; //创建一个新键
Reg.RootKey:=HKEY_LOCAL_MACHINE; //将根键设置为HKEY_LOCAL_MACHINE
Reg.OpenKey('SOFTWARE\Microsoft\windows\CurrentVersion\Run',true);//打开一个键
Reg.WriteString('TimeHint',Application.ExeName); //在Reg这个键中写入数据名称和数据数值
Reg.CloseKey;
end;
end.