unit Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Registry;
type
TForm1 =
class(TForm)
CheckBox1: TCheckBox;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
const
S = '
SOFTWARE/';
M = '
Microsoft/';
W = '
Windows/';
C = '
CurrentVersion';
var
Form1: TForm1;
Access: Integer;
App:
String;
implementation
{$R *.dfm}
procedure Reg_Read(root:HKEY;pfad, Eigenschaft, DeinString:
String;CheckBox:TCheckBox);
var
reg: TRegistry;
begin
reg := TRegistry.Create;
reg.RootKey := HKEY_LOCAL_MACHINE;
reg.OpenKey(Pfad, TRUE);
TRY
IF reg.ValueExists(Eigenschaft) = TRUE
THEN CheckBox.Checked := TRUE
ELSE CheckBox.Checked := FALSE;
FINALLY
reg.CloseKey;
reg.Free;
end;
end;
procedure Reg_Check(root:HKEY;pfad, Eigenschaft, DeinString:
String;CheckBox:TCheckBox);
var
reg: TRegistry;
begin
IF CheckBox.Checked
THEN
begin
reg := TRegistry.Create;
TRY
reg.RootKey := root;
reg.OpenKey(pfad, TRUE);
reg.WriteString(Eigenschaft, DeinString);
FINALLY
reg.Free;
end;
end else
begin
reg := TRegistry.Create;
TRY
reg.RootKey := root;
reg.OpenKey(Pfad, TRUE);
reg.DeleteValue(Eigenschaft);
FINALLY
reg.Free;
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Reg_Check(HKEY_LOCAL_MACHINE,S+M+W+C+'
/Run','
Auto',App,CheckBox1);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
App := '
"'+Application.ExeName+'
"';
Reg_Read(HKEY_LOCAL_MACHINE,S+M+W+C+'
/Run','
Auto',App,CheckBox1);
end;
end.