Click here to Skip to main content
13,256,716 members (51,921 online)
Click here to Skip to main content
Add your own
alternative version


24 bookmarked
Posted 24 Apr 2007

Help To Use EnvDTE - A Little Simple Library

, 24 Apr 2007
Rate this:
Please Sign up or sign in to vote.
A piece of library that can help to use Visual Studio Editor to search, write, change code directly in the code
Screenshot - screenshot.jpg


This article shows you how to get control of the currently running Visual Studio IDE instance. You can get a reference to the DTE object - the top-level object in the Visual Studio automation object model. Once you have a reference to this object, you can query for information about a solution, projects in a solution, start builds, etc.

My code is a very simple library, the point is to demonstrate it using the DTE object. For more detailed automation examples, you can look at the MSDN documentation, but this article should help you get started with a reference to the object model.

The DTE Object

DTE stands for "Development Tools Extensibility" and is the object's codeclass. It implements the interface "_DTE". You can find more information about the DTE object in the Visual Studio documentation under "DTE object", and in the document "Referencing the DTE object".

Using the Code

The file library contains a class VisualStudioIdea which defines a few of the relevant methods. The first thing we need is to be able to get at the system's Running Object Table. To do this, we'll need access to a couple of functions that live in ole32.dll:

[DllImport("ole32.dll", EntryPoint = "GetRunningObjectTable")]
static extern uint GetRunningObjectTable(uint res, out UCOMIRunningObjectTable ROT);
[DllImport("ole32.dll", EntryPoint = "CreateBindCtx")]
static extern uint CreateBindCtx(uint res, out UCOMIBindCtx ctx);

Now you are able to use Connect:

public static bool Connect()

public static Project GetCurrentProject() 
public static bool Disconnect()


This is a first raw version of this library born around March 2007.

About Elia Conchione

Elia Conchione is a software engineer living in Lugano, CH. Current programming interests include C, C++, C#, Linux, Unix, Mac OS X, Safe Code, encryption applications.


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


About the Author

Elia Conchione
Software Developer (Senior)
Italy Italy
Elia Conchione is a Banking software engineer from 1986, living in Cittadella, Padova, Italy. Current programming interests include C, C++, C#, Linux, Unix, Mac OS X, Safe Code, encryption applications.

You may also be interested in...


Comments and Discussions

GeneralSmall change suggested Pin
Russ Suter10-May-08 11:45
memberRuss Suter10-May-08 11:45 
GeneralRe: Small change suggested Pin
dfjklsdfjkljklm8-Jan-09 22:28
memberdfjklsdfjkljklm8-Jan-09 22:28 
QuestionLicense?? Pin
Coolite9-May-08 15:06
memberCoolite9-May-08 15:06 
Generalvery good Pin
laleh.rajabi1-Mar-08 2:14
memberlaleh.rajabi1-Mar-08 2:14 
GeneralGreate !!! Pin
Abhijit Jana5-Dec-07 21:44
memberAbhijit Jana5-Dec-07 21:44 
GeneralGood! Pin
montanacarlo25-Apr-07 23:30
membermontanacarlo25-Apr-07 23:30 
GeneralExamples Pin
Priyank Bolia24-Apr-07 7:52
memberPriyank Bolia24-Apr-07 7:52 
GeneralRe: Examples Pin
Elia Conchione25-Apr-07 21:50
memberElia Conchione25-Apr-07 21:50 

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.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171114.1 | Last Updated 24 Apr 2007
Article Copyright 2007 by Elia Conchione
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid