Back to Amir Israeli Homepage

[CAutoLoader : Auto launching an app on Windows Startup ]

This article was contributed by Amir Israeli Amir Israeli.
Amir Israeli Web Site
This class is based on "Launching an Application on Windows Startup" article (September 2000) Written By : Partha Sarathi Dhar.

Environment: Win 95/98 VC6 SP4

This article describes a class called "CAutoLoader" , it doesn't describe several companion classes that exist within source code + example project.
These are described in Amir Israeli Web Site
This clss allows your module (library/application/service) be loaded on windows startup. It does the job by installing an entry with the path to the app within the registry
"HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\" It installs your app path under a unique value name under the proper key: that will determine the functionality : Run, RunService etc ...
Unique value name will be created by a contatenation of non-null strings describing " lpszCompany + lpszApplication + lpszModule + lpszVersion" ,The function uses an already existing function for string concatenation (in CPath) so the value is at directory form (with \\ between parts).

How to use?
The best method to use that class is to instantiate an object within the InitInstance() : Here is the code that does that:

BOOL CDemoAutoLoaderApp::InitInstance() //start init instance
{
	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

//Here construction of "CAutoLoader" object

	CAutoLoader  m_autoLoader(_T("run"),_T("Amir Israeli"),_T("DemoAutoLoader"),_T("Main"),_T("1.0"));


// continue with InitInstance() ...
// ...
The code :
CAutoLoader m_autoLoader(_T("run"),_T("Amir Israeli"),_T("DemoAutoLoader"),_T("Main"),_T("1.0"));
creates an object that will be installed under the key "run" unique value is "Amir Israeli\\DemoAutoLoader\\Main\\1.0"
Behind the scenes the constructor calls some public functions: for "run" it calls
BOOL SetType(LPCTSTR lpszTypeLoad);
for creation of value it calls:
BOOL SetValue(LPCTSTR lpszCompany,LPCTSTR lpszApplication,LPCTSTR lpszModule,LPCTSTR lpszVersion);
Notice that you have another function : "InstallOnce"
LPCTSTR lpszAppPath,LPCTSTR lpszTypeLoad,LPCTSTR lpszCompany, LPCTSTR lpszApplication,LPCTSTR lpszModule,LPCTSTR lpszVersion);
You aren't supposet that function in the same method : instead , after you install some app and with that it will be invoked the next time of startup you set all previous parameters and the path to that app (the first parameter).

Downloads

Download demo project - 57 Kb
Download source - 12 Kb

History

Date Posted: September 30, 2000

Home  |  Links  |  About

Make your own free website on Tripod.com