Annonceindlæg fra Systematic
09. januar 2002 - 17:28
#1
procedure SetAutoStart(CheckState : boolean); const RunKey = \'\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\'; var Registry : TRegistry; begin Registry := TRegistry.Create; try Registry.RootKey := HKEY_CURRENT_USER; if Registry.OpenKey(RunKey, FALSE) then begin case CheckState of // Disables AutoStart FALSE : Registry.DeleteValue(Application.Title); // Enables AutoStart TRUE : Registry.WriteString(Application.Title, ParamStr(0)); end; end; finally Registry.Free; end; end;
09. januar 2002 - 17:35
#5
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Registry, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure SetAutoStart(CheckState : boolean); const RunKey = \'\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\'; var Registry : TRegistry; begin Registry := TRegistry.Create; try Registry.RootKey := HKEY_CURRENT_USER; if Registry.OpenKey(RunKey, FALSE) then begin case CheckState of FALSE : Registry.DeleteValue(Application.Title); TRUE : Registry.WriteString(Application.Title, ParamStr(0)); end; end; finally Registry.Free; end; end; procedure TForm1.Button1Click(Sender: TObject); begin SetAutoStart(true); end; procedure TForm1.Button2Click(Sender: TObject); begin SetAutoStart(false); end; end.