Web Design that taps into the haromny and vision of your dreams.

Add Or Remove Startup Items in Delphi

Autorun applications with Delphi

Written By on in Coding

67 words, estimated reading time 1 minutes.

These two short methods will allow you to easily add or remove program startup entries to the system registry to auto load applications when Windows loads.

procedure RunOnStartup(sProgTitle, sCmdLine: string; bRunOnce: boolean );
var
  sKey : string;
  reg  : TRegIniFile;
begin
  if( bRunOnce )then
    sKey := 'Once'
  else
    sKey := '';
 
  reg := TRegIniFile.Create( '' );
  reg.RootKey := HKEY_LOCAL_MACHINE;
  reg.WriteString('SoftwareMicrosoftWindowsCurrentVersionRun' + sKey + #0, sProgTitle, sCmdLine );
  reg.Free;
end;
 
procedure RemoveOnStartup(sProgTitle: string);
var
  sKey : string;
  reg  : TRegIniFile;
begin
  reg := TRegIniFile.Create( '' );
  reg.RootKey := HKEY_LOCAL_MACHINE;
  reg.DeleteKey('SoftwareMicrosoftWindowsCurrentVersionRun', sProgTitle);
  reg.Free;
end;

Last updated on: Saturday 24th June 2017

 

Comments

There are no comments for this post. Be the first!

 

 

Leave a Reply

Your email address will not be published.





If you find something abusive or that does not comply with our terms or guidelines please flag it as inappropriate.

 

Copyright © 2001-2018 Tim Trott, all rights reserved. Web Design by Azulia Designs

This web page is licensed for your personal, private, non-commercial use only.

Disclaimer, Privacy & LegalSitemapContact Me