VS2008:
要使用的编程标识符 (ProgID) 是 VisualStudio.DTE.9.0。您可以将返回的对象强制转换成一个 DTE2 接口
// Create a new instance of Visual Studio.
EnvDTE80.DTE2 myDTE2;
myDTE2 = (EnvDTE80.DTE2)Microsoft.VisualBasic.Interaction.
CreateObject( " VisualStudio.DTE.9.0 " , "" );
或者:
// Get an instance of the currently running Visual Studio IDE.
EnvDTE80.DTE2 dte2;
dte2 = (EnvDTE80.DTE2)System.Runtime.InteropServices.Marshal.
GetActiveObject( " VisualStudio.DTE.9.0 " );