Title: create a registry entry in the autorun key?
{
There'saRunOncekeyintheregistry.
Whenauserlogson,theprogramsintherun-oncelistarerunjustonce,
andthentheentrieswillberemoved.
The"runonce"keyisnormallyusedbysetupprogramstoinstall
softwareafteramachinehasbeenrebooted.
}
{
JedeAnwendung,dieimSchlsselRunOnceaufgefhrtist,wird
beimnchstenWindowsstartausgefhrtundanschlieendwieder
ausderRegistryentfernt.BetrifftAnwendungen,dienureinmal
mitWindowsgestartetwerdensollen.NormalerweisewirddieserSchlssel
vonSetupProgrammengenutzt,umnacheinemNeustartmitderInstallation
fortzufahren.
}
//Addtheapplicationtotheregistry...
//AnwendungindieRegistryaufnehmen...
procedureDoAppToRunOnce(RunName,AppName:string);
var
Reg:TRegistry;
begin
Reg:=TRegistry.Create;
withRegdo
begin
RootKey:=HKEY_LOCAL_MACHINE;
OpenKey('Software\Microsoft\Windows\CurrentVersion\RunOnce',True);
WriteString(RunName,AppName);
CloseKey;
Free;
end;
end;
//Checkiftheapplicationisintheregistry...
//Prfen,obAnwendunginderRegistryvorhandenist...
functionIsAppInRunOnce(RunName:string):Boolean;
var
Reg:TRegistry;
begin
Reg:=TRegistry.Create;
withRegdo
begin
RootKey:=HKEY_LOCAL_MACHINE;
OpenKey('Software\Microsoft\Windows\CurrentVersion\RunOnce',False);
Result:=ValueExists(RunName);
CloseKey;
Free;
end;
end;
//Removetheapplicationfromtheregistry...
//AnwendungausderRegistryentfernen...
procedureDelAppFromRunOnce(RunName:string);
var
Reg:TRegistry;
begin
Reg:=TRegistry.Create;
withRegdo
begin
RootKey:=HKEY_LOCAL_MACHINE;
OpenKey('Software\Microsoft\Windows\CurrentVersion\RunOnce',True);
ifValueExists(RunName)thenDeleteValue(RunName);
CloseKey;
Free;
end;
end;
{
Applicationsunderthekey"Run"willbeexecuted
eachtimetheuserlogson.
{
{
JedeAnwendung,dieimSchlsselRunaufgefhrtist,wirdbeim
jedemWindowsstartausgefhrt.BetrifftAnwendungen,dieimmer
mitWindowsgestartetwerdensollen...
}
//Addtheapplicationtotheregistry...
//AnwendungindieRegistryaufnehmen...
procedureDoAppToRun(RunName,AppName:string);
var
Reg:TRegistry;
begin
Reg:=TRegistry.Create;
withRegdo
begin
RootKey:=HKEY_LOCAL_MACHINE;
OpenKey('Software\Microsoft\Windows\CurrentVersion\Run',True);
WriteString(RunName,AppName);
CloseKey;
Free;
end;
end;
//Checkiftheapplicationisintheregistry...
//Prfen,obAnwendunginderRegistryvorhandenist...
functionIsAppInRun(RunName:string):Boolean;
var
Reg:TRegistry;
begin
Reg:=TRegistry.Create;
withRegdo
begin
RootKey:=HKEY_LOCAL_MACHINE;
OpenKey('Software\Microsoft\Windows\CurrentVersion\Run',False);
Result:=ValueExists(RunName);
CloseKey;
Free;
end;
end;
//Removetheapplicationfromtheregistry...
//AnwendungausderRegistryentfernen...
procedureDelAppFromRun(RunName:string);
var
Reg:TRegistry;
begin
Reg:=TRegistry.Create;
withRegdo
begin
RootKey:=HKEY_LOCAL_MACHINE;
OpenKey('Software\Microsoft\Windows\CurrentVersion\Run',True);
ifValueExists(RunName)thenDeleteValue(RunName);
CloseKey;
Free;
end;
end;
//Examples,Beispiele
//Addapp,Anwendungaufnehmen...
DoAppToRun('Programm','C:\Programs\XYZ\Program.exe');
//Isappthere?IstAnwendungvorhanden?
ifIsAppInRun('Programm')then...
//Removeapp,Anwendungentfernen
DelAppFromRun('Programm');