VSProject.DTE プロパティ

トップレベルの機能拡張オブジェクトを取得します。

名前空間:  VSLangProj
アセンブリ:  VSLangProj (VSLangProj.dll 内)

構文

'宣言
ReadOnly Property DTE As DTE
    Get
DTE DTE { get; }
property DTE^ DTE {
    DTE^ get ();
}
abstract DTE : DTE
function get DTE () : DTE

プロパティ値

型: EnvDTE.DTE
DTE オブジェクトを返します。

解説

Visual Studio では、DTE オブジェクトがオートメーション モデルのルート オブジェクトです。他のオブジェクト モデルでは、多くの場合、"アプリケーション" と呼ばれます。

[Visual Basic]

Sub DTEExample(ByVal dte As DTE2)

    Dim msg As String = _
        "The current Output Window object belongs to the "
    Dim output As OutputWindow = dte.ToolWindows.OutputWindow

    If IsMacrosIDE(output.DTE) Then
        MsgBox(msg & "macros IDE.")
    Else
        MsgBox(msg & "main IDE.")
    End If

    output = CType(dte.MacrosIDE, DTE2).ToolWindows.OutputWindow

    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 
        ' isn't the main DTE object
        If IsNothing(ide.MacrosIDE) = False Then
            val = False
        End If

    Catch ex As Exception
    End Try

    Return val

End Function

[C#]

public void DTEExample(DTE2 dte)
{
    string msg = "The current Output Window object belongs to the ";
    OutputWindow output = dte.ToolWindows.OutputWindow;

    if (IsMacrosIDE(output.DTE))
        MessageBox.Show(msg + "macros IDE.");
    else
        MessageBox.Show(msg + "main IDE.");

    output = ((DTE2)dte.MacrosIDE).ToolWindows.OutputWindow;

    if (IsMacrosIDE(output.DTE))
        MessageBox.Show(msg + "macros IDE.");
    else
        MessageBox.Show(msg + "main IDE.");
}

bool IsMacrosIDE(DTE ide)
{
    bool val = true;

    try
    {
        // The MacrosIDE property will throw an exception if ide 
        // isn't the main DTE object
        if (ide.MacrosIDE != null)
            val = false;
    }
    catch (Exception ex)
    {
    }

    return val;
}

.NET Framework セキュリティ

  • 直前の呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されているコードから使用することはできません。 詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

参照

VSProject インターフェイス

VSLangProj 名前空間

その他の技術情報

方法 : オートメーション オブジェクト モデルのコード例をコンパイルおよび実行する