关闭

设置自运行程序

548人阅读 评论(0) 收藏 举报

 
 

原代码如下:

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.

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:788次
    • 积分:16
    • 等级:
    • 排名:千里之外
    • 原创:1篇
    • 转载:0篇
    • 译文:0篇
    • 评论:0条
    文章存档
    阅读排行
    评论排行