다음을 통해 공유


Window2.DTE 속성

최상위 확장성 개체를 가져옵니다.

네임스페이스:  EnvDTE80
어셈블리:  EnvDTE80(EnvDTE80.dll)

구문

‘선언
ReadOnly Property DTE As DTE
DTE DTE { get; }
property DTE^ DTE {
    DTE^ get ();
}
abstract DTE : DTE with get
function get DTE () : DTE

속성 값

형식: DTE
DTE 개체

설명

Visual Studio에서 DTE 개체는 자동화 모델의 루트이며 다른 개체 모델에서는 이를 "Application"이라고도 합니다.

예제

이 예제에서는 Window2 개체를 통해 가져온 DTE 개체를 사용하여 출력 창이 매크로 IDE에 속해 있는지 Visual Studio IDE에 속해 있는지 확인합니다.

이 예제를 추가 기능으로 실행하는 방법에 대한 자세한 내용은 방법: 자동화 개체 모델 코드의 예제 컴파일 및 실행을 참조하십시오.

Imports EnvDTE
Imports EnvDTE80
Public Sub OnConnection(ByVal application As Object, _
 ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, _
 ByRef custom As Array) Implements IDTExtensibility2.OnConnection
    _applicationObject = CType(application, DTE2)
    _addInInstance = CType(addInInst, AddIn)
    DTEExample(_applicationObject)
End Sub
Sub DTEExample(ByVal dte As DTE2)
    Dim msg As String = _
    "The current Output Window object belongs to the "
    Dim output As Window2 = _
 CType(_applicationObject.Windows.Item _
(Constants.vsWindowKindOutput), Window2)
    If IsMacrosIDE(output.DTE) Then
        MsgBox(msg & "macros IDE.")
    Else
        MsgBox(msg & "main IDE.")
    End If
    output = _
 CType(dte.MacrosIDE.Windows.Item(Constants.vsWindowKindOutput), _
 Window2)
    If IsMacrosIDE(output.DTE) Then
        MsgBox(msg & "macros IDE.")
    Else
        MsgBox(msg & "main IDE.")
    End If
End Sub
Function IsMacrosIDE(ByVal ide As DTE) As Boolean
    Dim val As Boolean = True
    Try
    ' The MacrosIDE property will throw an exception if ide 
    ' is not the main DTE object.
    If IsNothing(ide.MacrosIDE) = False Then
        val = False
    End If
    Catch ex As Exception
    End Try
    Return val
End Function
using EnvDTE;
using EnvDTE80;
using System.Windows.Forms;
public void OnConnection(object application, 
ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
    _applicationObject = (DTE2)application;
    _addInInstance = (AddIn)addInInst;
    DTEExample(_applicationObject);
}
public void DTEExample(DTE2 dte)
{
    String msg = "The current Output Window object belongs to the ";
    Window2 output = 
(Window2)_applicationObject.Windows.Item(Constants.vsWindowKindOutput);
    if (IsMacrosIDE(output.DTE))
        MessageBox.Show(msg + "macros IDE.");
    else
        MessageBox.Show(msg + "main IDE.");
    output = 
(Window2)_applicationObject.Windows.Item
(Constants.vsWindowKindMacroExplorer);
    if (IsMacrosIDE(output.DTE))
        MessageBox.Show(msg + "macros IDE.");
    else
        MessageBox.Show(msg + "main IDE.");
}
public bool IsMacrosIDE(DTE ide)
{
    try
    {
        bool val = true;
        if (ide.MacrosIDE == null)
            val = false;
    }
    catch (Exception ex)
    {
    }
    return val;
}

.NET Framework 보안

참고 항목

참조

Window2 인터페이스

EnvDTE80 네임스페이스