Click here to Skip to main content
15,867,594 members
Articles / Desktop Programming / MFC
Article

Adding your application to the Windows Startup

Rate me:
Please Sign up or sign in to vote.
4.41/5 (13 votes)
10 Jul 2001 91.5K   3K   41   10
An article on including an application in the Windows startup list

Introduction

Sometimes you want to make you application run everytime Windows starts up. One approach is to develop a service, but it will work just in NT or 2K boxes. To make it happen in Win95/98 boxes is necessary to change the registry settings.

The registry key is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run to all users and HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run to the current user.

To make this task easier I wrote a wrapper class (CWinStartup) that adds and removes applications from the startup

bool AddApp(HINSTANCE hInst, LPCTSTR lpszName, StartupUser user) Add an app to the startup through the HINSTANCE
bool AddApp(LPCTSTR lpszName, LPCTSTR lpszPath, StartupUser user) Add the app according to the path defined
bool RemoveApp(LPCTSTR lpszName, StartupUser user) Removes the app from the registry

All the methods are static. This class has been tested on Win2K boxes only, but as far as I'm concerned it works in all Windows versions.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Architect VisionOne AG
Switzerland Switzerland
XicoLoko is a brazilian developer based in Switzerland.

Comments and Discussions

 
GeneralThank you Pin
quangson200210-Nov-07 15:35
quangson200210-Nov-07 15:35 
GeneralThanks Pin
joyvinod13-Apr-05 1:11
joyvinod13-Apr-05 1:11 
Generali did't work....help me... Pin
srinu_gari2-Oct-02 20:31
srinu_gari2-Oct-02 20:31 
Questionanother way? Pin
rebel28-Mar-02 3:16
rebel28-Mar-02 3:16 
AnswerRe: another way? Pin
KarstenK21-May-02 22:20
mveKarstenK21-May-02 22:20 
GeneralHelp for Run as Service or Application Pin
Norman Bates14-Jul-01 5:06
Norman Bates14-Jul-01 5:06 
QuestionWill it start before the password window? Pin
Crocmort12-Jul-01 9:05
Crocmort12-Jul-01 9:05 
AnswerRe: Will it start before the password window? Pin
Ed Dixon12-Jul-01 10:57
Ed Dixon12-Jul-01 10:57 
GeneralRe: Will it start before the password window? Pin
Crocmort12-Jul-01 11:48
Crocmort12-Jul-01 11:48 
GeneralRe: Will it start before the password window? Pin
Ed Dixon12-Jul-01 12:07
Ed Dixon12-Jul-01 12:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.