佳伦美石 發表於 2014-7-29 08:59:40

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

<p>Delphi可以通过创建开机启动项键值的方法,将程序添加到开机启动项中。通过本实例代码就可以为您的程序添加到快速启动中,随着Windows一起启动,开机即运行的程序。该实例代码简单,主要是通过添加注册表键值来实现。<br />
具体的功能代码如下所示:</p>
<div class="jb51code">
<pre class="brush:delphi;">
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.</pre>
</div>
                           
                            <div class="art_xg">
                              <b>您可能感兴趣的文章:</b><ul><li>Delphi7中群发Email邮件的方法</li><li>delphi实现保存和读取图片的方法</li><li>Delphi远程连接Mysql的实现方法</li><li>Delphi实现获取句柄并发送消息的方法</li><li>Delphi实现木马自我拷贝方法</li><li>Delphi实现窗口文字淡入淡出渐变效果的方法</li><li>Delphi实现获取磁盘空间大小的方法</li><li>Delphi中对时间操作方法汇总</li><li>delphi7连接mysql5的实现方法</li><li>delphi实现将BMP格式图形转化为JPG格式图形的方法</li></ul>
                            </div>

                        </div>
                        <!--endmain-->
頁: [1]
查看完整版本: Delphi创建开机启动项的方法示例