Debugger3 インターフェイス
更新 : 2007 年 11 月
Debugger3 を使用すると、デバッガの状態やデバッグ中のプログラムの状態を問い合わせたり、操作したりできます。Debugger3 は、Debugger2 インターフェイスおよび Debugger インターフェイスよりも優先されます。
名前空間 : EnvDTE90
アセンブリ : EnvDTE90 (EnvDTE90.dll 内)
構文
'宣言
<GuidAttribute("87DFC8DA-67B4-4954-BB89-6A277A50BAFC")> _
Public Interface Debugger3 _
Implements Debugger2
'使用
Dim instance As Debugger3
[GuidAttribute("87DFC8DA-67B4-4954-BB89-6A277A50BAFC")]
public interface Debugger3 : Debugger2
[GuidAttribute(L"87DFC8DA-67B4-4954-BB89-6A277A50BAFC")]
public interface class Debugger3 : Debugger2
public interface Debugger3 extends Debugger2
解説
デバッガは、以下の例に示すように、Debugger プロパティを使用して DTE2 オブジェクトを通じて利用できます。IDE (統合開発環境) で 1 つのデバッガ オブジェクトを利用できます。
例
Imports System
Imports EnvDTE
Imports EnvDTE90
Imports EnvDTE90
Imports System.Diagnostics
Public Module Module1
'This function returns true if the debugger is actively debugging.
Function IsDebugging() As Boolean
Dim debugger As EnvDTE90.Debugger3debugger = DTE.Debugger
If (debugger Is Nothing) Then
MsgBox("Debugger doesn't exist! Fatal error.")
IsDebugging = false
Else
IsDebugging = (debugger.CurrentMode <> _
dbgDebugMode.dbgDesignMode)
End If
End Function
End Module
// The following C++ program can be run from the command line.
// It detects whether an instance of Visual Studio is currently
// running,and if so, prints a message stating whether its debugger
// is actively debugging.
#include <stdio.h>
#import "dte90.olb" raw_interfaces_only named_guids
using namespace EnvDTE90;
int main(void)
{
int nRet = 0;
CoInitialize(NULL);
IUnknownPtr pUnk;
GetActiveObject(CLSID_DTE, NULL, &pUnk);
if (pUnk == NULL) {
printf ("No instance of Visual Studio is running.\n");
}
else {
_DTEPtr pDTE = pUnk;
if (pDTE) {
DebuggerPtr pDebugger;
if (SUCCEEDED(pDTE->get_Debugger(&pDebugger3)) &&
pDebugger3
!= NULL){
dbgDebugMode mode;
if (SUCCEEDED(pDebugger3->get_CurrentMode(&mode))) {
if (mode != dbgDesignMode) {
printf("Debugger is active.\n");
nRet = 1;
}
else {
printf("Debugger is not active.\n");
}
}
}
}
}
CoUninitialize();
return nRet;
}