您的位置:首页 > 编程语言 > Delphi

Delphi创建开机启动项的方法示例

2016-05-30 17:17 465 查看
Delphi可以通过创建开机启动项键值的方法,将程序添加到开机启动项中。通过本实例代码就可以为您的程序添加到快速启动中,随着Windows一起启动,开机即运行的程序。该实例代码简单,主要是通过添加注册表键值来实现。
具体的功能代码如下所示:
unit dy97;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,registry, StdCtrls, ExtCtrls;

type
TForm1 = class(TForm)
Label1: TLabel;
Image1: TImage;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure zdyx(a,b: string;c: boolean);
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

{ TForm1 }

procedure TForm1.zdyx(a, b: string; c: boolean);
var
d: string;
e: TReginiFile;
begin
if c then
d := 'once'
else
d:= '';
e := TRegIniFile.Create('');
e.RootKey := HKEY_LOCAL_MACHINE;
e.WriteString('software\microsoft\windows\currentversion\run'+d +#0,a,b);
e.Free ;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
self.zdyx('ZDYX',application.ExeName,false);
end;
end.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: