When I open visual studio to do some code work, I often need to run several utiltiy to help me make my work easy and with funs. I write this very simple addin to do these things automatically, when start visual studio, it load informations from an ini file, and launch the utility applications which I need, and close them when I exit visual studio.
Using the code
The code is very simple, there's only one class and several functions.
first the class CAppInfo, it descript the application we want to run:
string strWindowTitle; string strAppPath; BOOL bLoaded; CAppInfo & operator =(CAppInfo & ai)
strWindowTitle = ai.strWindowTitle;
strAppPath = ai.strAppPath;
bLoaded = ai.bLoaded;
return * this;
Next one variable and four functions in CConect:
void LoadAppInfo(LPCTSTR strIniFile); void LaunchApp(CAppInfo & ai); void StartApp(LPCTSTR strIniFile); void EndApp(void);
Their functions descript in the comment.
Last, call our functions at appropriate time, in CConnect class:
STDMETHODIMP CConnect::OnStartupComplete (SAFEARRAY ** )
STDMETHODIMP CConnect::OnBeginShutdown (SAFEARRAY ** )
The ini file
It use an ini file named AutoStart.ini to descript the applications info, it must be put to your system folder(C:\\windows or something like that).
if you want to launch "n" applications, it must have n sections. The sections named [Application 1], [Application 2], ..., [Application n], each section descripted an application. Below is a sample:
WindowTitle="Perfect Keyboard - cpp.4pk"
AppPath="E:\Program Files\Perfect Keyboard AS\pk32.exe"
AppPath="E:\Program Files\Hamsin Clipboard\HamsinClipboard.exe"
We use "ClassName" and "WindowTitle" to find the application's main window so we can close it by send a WM_CLOSE message when we exit the visual studio, so they are optional.
We need the "AppPath" to launch the application, so it necessary.
2007-05-16 original version posted.