IDTCommandTarget.Exec 메서드

지정한 명명된 명령을 실행합니다.

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

구문

‘선언
Sub Exec ( _
    CmdName As String, _
    ExecuteOption As vsCommandExecOption, _
    ByRef VariantIn As Object, _
    <OutAttribute> ByRef VariantOut As Object, _
    <OutAttribute> ByRef Handled As Boolean _
)
void Exec(
    string CmdName,
    vsCommandExecOption ExecuteOption,
    ref Object VariantIn,
    out Object VariantOut,
    out bool Handled
)
void Exec(
    [InAttribute] String^ CmdName, 
    [InAttribute] vsCommandExecOption ExecuteOption, 
    [InAttribute] Object^% VariantIn, 
    [InAttribute] [OutAttribute] Object^% VariantOut, 
    [InAttribute] [OutAttribute] bool% Handled
)
abstract Exec : 
        CmdName:string * 
        ExecuteOption:vsCommandExecOption * 
        VariantIn:Object byref * 
        VariantOut:Object byref * 
        Handled:bool byref -> unit
function Exec(
    CmdName : String, 
    ExecuteOption : vsCommandExecOption, 
    VariantIn : Object, 
    VariantOut : Object, 
    Handled : boolean
)

매개 변수

  • CmdName
    형식: String

    실행할 명령의 이름입니다.

  • VariantIn
    형식: Object%

    명령에 전달되는 값입니다.

  • VariantOut
    형식: Object%

    명령 실행 후 호출자 Exec 메서드로 다시 전달되는 값입니다.

  • Handled
    형식: Boolean%

설명

다음 예제에서는 Command 개체와 이 개체의 AddNamedCommandAddControl 메서드, IDTCommandTarget 인터페이스와 이 인터페이스의 Exec 및 QueryStatus 메서드를 사용하여 추가 기능을 Visual Studio의 도구 메뉴에 명령으로 나타내는 방법을 보여 줍니다. 참고로 이 코드는 매크로에서 동작하지 않습니다.

예제

Implements IDTCommandTarget

Dim applicationObject As EnvDTE.DTE
Dim addInInstance as EnvDTE.AddIn
   
Dim objAddIn As AddIn = CType(addInInst, AddIn)
Dim CommandObj As Command
Try
   CommandObj = applicationObject.Commands.AddNamedCommand(objAddIn, "MyAddin1", "MyAddin1", "Executes the command for MyAddin1", True, 59, Nothing, 1 + 2)
   '1+2 == vsCommandStatusSupported+vsCommandStatusEnabled
   CommandObj.AddControl(applicationObject.CommandBars.Item("Tools"))
Catch e as System.Exception
End Try

Public Sub Exec(ByVal cmdName As String, ByVal executeOption As vsCommandExecOption, ByRef varIn As Object, ByRef varOut As Object, ByRef handled As Boolean) Implements IDTCommandTarget.Exec
   handled = False
   If (executeOption = vsCommandExecOption.vsCommandExecOptionDoDefault) Then
      If cmdName = "MyAddin1.Connect.MyAddin1" Then
         handled = True
         Exit Sub
      End If
   End If
End Sub
   
Public Sub QueryStatus(ByVal cmdName As String, ByVal neededText As vsCommandStatusTextWanted, ByRef statusOption As vsCommandStatus, ByRef commandText As Object) Implements IDTCommandTarget.QueryStatus
   If neededText = EnvDTE.vsCommandStatusTextWanted.vsCommandStatusTextWantedNone Then
      If cmdName = "MyAddin1.Connect.MyAddin1" Then
         statusOption = CType(vsCommandStatus.vsCommandStatusEnabled & vsCommandStatus.vsCommandStatusSupported, vsCommandStatus)
      Else
         statusOption = vsCommandStatus.vsCommandStatusUnsupported
      End If
   End If
End Sub  

.NET Framework 보안

참고 항목

참조

IDTCommandTarget 인터페이스

EnvDTE 네임스페이스