Click here to Skip to main content
Click here to Skip to main content

AutoStart - Launch applications automatically when starting visual studio

, 15 May 2007
Rate this:
Please Sign up or sign in to vote.
This is an addin for visual studio 2003 and 2005, it launches applications which your defined automatically when starting visual studio

Introduction

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:

class CAppInfo
{
public:
 string strWindowTitle;    // the main window title
 string strAppPath;    // the application's exe file path
 BOOL bLoaded;    // indicate if the application is launch by this addin
 CAppInfo & operator =(CAppInfo & ai)
 {
  strWindowTitle = ai.strWindowTitle;
  strAppPath = ai.strAppPath;
  bLoaded = ai.bLoaded;
  return * this;
 }
};

Next one variable and four functions in CConect:

protected:
    list<cappinfo> AppList;    // store the applications info loaded from an ini file

    void LoadAppInfo(LPCTSTR strIniFile);    // load applications info from ini file
    void LaunchApp(CAppInfo & ai);    // launch an application
    void StartApp(LPCTSTR strIniFile);    // load applications info from ini file and launch then all
    void EndApp(void);    // close all launched applications 

Their functions descript in the comment.

Last, call our functions at appropriate time, in CConnect class:

STDMETHODIMP CConnect::OnStartupComplete (SAFEARRAY ** /*custom*/ )
{
    StartApp(STRINIFILE);
    return S_OK;
}

STDMETHODIMP CConnect::OnBeginShutdown (SAFEARRAY ** /*custom*/ )
{
    EndApp();
    return S_OK;
}

That's all.

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:

[Application 1]
ClassName=AfxFrameOrView42s
WindowTitle="Perfect Keyboard - cpp.4pk"
AppPath="E:\Program Files\Perfect Keyboard AS\pk32.exe"
[Application 2]
ClassName=HamsinClipboardClassName
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.

History

2007-05-16 original version posted.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Satervalley

China China
No Biography provided

Comments and Discussions

 
QuestionHello please help Pinmemberrawaha8-Jan-11 2:28 
AnswerRe: Hello please help PinmemberSatervalley28-Apr-11 17:29 
Rantthanks PinmemberMilad.D23-Jun-10 0:33 

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

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

| Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 15 May 2007
Article Copyright 2007 by Satervalley
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid