Delphi可以通過(guò)創(chuàng)建開(kāi)機(jī)啟動(dòng)項(xiàng)鍵值的方法,將程序添加到開(kāi)機(jī)啟動(dòng)項(xiàng)中。通過(guò)本實(shí)例代碼就可以為您的程序添加到快速啟動(dòng)中,隨著Windows一起啟動(dòng),開(kāi)機(jī)即運(yùn)行的程序。該實(shí)例代碼簡(jiǎn)單,主要是通過(guò)添加注冊(cè)表鍵值來(lái)實(shí)現(xiàn)。
具體的功能代碼如下所示:
unit dy97;interfaceuses 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.
新聞熱點(diǎn)
疑難解答
圖片精選