设置自运行程序

 
 

原代码如下:

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.

阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

设置自运行程序

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭