IMPORTANT PLEASE READ!
Website development and design blog, tutorials and inspiration

Add Or Remove Startup Items in Delphi

Autorun applications with Delphi

By , Written on in Software Engineering

Add Or Remove Startup Items in Delphi

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.

  1. procedure RunOnStartup(sProgTitle, sCmdLine: string; bRunOnce: boolean );
  2. var
  3. sKey : string;
  4. reg : TRegIniFile;
  5. begin
  6. if( bRunOnce )then
  7. sKey := 'Once'
  8. else
  9. sKey := '';
  10.  
  11. reg := TRegIniFile.Create( '' );
  12. reg.RootKey := HKEY_LOCAL_MACHINE;
  13. reg.WriteString('SoftwareMicrosoftWindowsCurrentVersionRun' + sKey + #0, sProgTitle, sCmdLine );
  14. reg.Free;
  15. end;
  16.  
  17. procedure RemoveOnStartup(sProgTitle: string);
  18. var
  19. sKey : string;
  20. reg : TRegIniFile;
  21. begin
  22. reg := TRegIniFile.Create( '' );
  23. reg.RootKey := HKEY_LOCAL_MACHINE;
  24. reg.DeleteKey('SoftwareMicrosoftWindowsCurrentVersionRun', sProgTitle);
  25. reg.Free;
  26. end;

Last updated on: Saturday 24th June 2017

Did you Like this Post? Why not Like us on Facebook?

 

Comments

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

Leave a Reply

Your email address will not be published.