Thema: Delphi Autostart mit Delphi

Einzelnen Beitrag anzeigen

MathiasSimmack
(Gast)

n/a Beiträge
 

Re: Autostart mit Delphi

  Alt 2. Jul 2004, 16:55
Besser:
Delphi-Quellcode:
procedure Autostart(const fForAllUsers: boolean = true);
const
  RootKey : array[boolean]of HKEY =
    (HKEY_CURRENT_USER,HKEY_LOCAL_MACHINE);
var
  reg : TRegistry;
begin
  reg := TRegistry.Create;
  if(reg <> nil) then
  try
    reg.RootKey := RootKey[IsAdmin and fForAllUsers];

    if(reg.OpenKey('Software\Microsoft\Windows\CurrentVersion\Run',
      true)) then
    try
      reg.WriteString('Programm-Name', paramstr(0));
    finally
      reg.CloseKey;
    end;
  finally
    free;
  end;
end;
benötigt lediglich: [dp]"IsAdmin"[/dp] von Nico.
  Mit Zitat antworten Zitat