原代码如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,Registry, Buttons, StdCtrls;
type
TForm1 = class(TForm)
OpenDialog1: TOpenDialog;
Button1: TButton;
Edit1: TEdit;
Label1: TLabel;
SpeedButton1: TSpeedButton;
procedure Button1Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
registerTemp:TRegistry;
begin
registertemp:=tregistry.Create ;
with registertemp do
begin
Rootkey:=hkey_local_machine;
if openkey('software/MIcrosoft/windows/CurrentVersion/run',true) then
begin
WriteString(extractfilename(edit1.Text ),edit1.Text );
showMessage('操作成功');
end
else
showMessage ('操作失败');
end;
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
if openDialog1.Execute then
edit1.Text :=opendialog1.FileName;
end;
end.