共用方式為


OleMenuCommandService.IOleCommandTarget.Exec Method

This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.

Executes the selected command.

Namespace:  Microsoft.VisualStudio.Shell
Assemblies:   Microsoft.VisualStudio.Shell.9.0 (in Microsoft.VisualStudio.Shell.9.0.dll)
  Microsoft.VisualStudio.Shell (in Microsoft.VisualStudio.Shell.dll)
  Microsoft.VisualStudio.Shell.10.0 (in Microsoft.VisualStudio.Shell.10.0.dll)

Syntax

'宣告
Private Function Exec ( _
    ByRef guidGroup As Guid, _
    nCmdId As UInteger, _
    nCmdExcept As UInteger, _
    pIn As IntPtr, _
    vOut As IntPtr _
) As Integer Implements IOleCommandTarget.Exec
'用途
Dim instance As OleMenuCommandService
Dim guidGroup As Guid
Dim nCmdId As UInteger
Dim nCmdExcept As UInteger
Dim pIn As IntPtr
Dim vOut As IntPtr
Dim returnValue As Integer

returnValue = CType(instance, IOleCommandTarget).Exec(guidGroup, _
    nCmdId, nCmdExcept, pIn, vOut)
int IOleCommandTarget.Exec(
    ref Guid guidGroup,
    uint nCmdId,
    uint nCmdExcept,
    IntPtr pIn,
    IntPtr vOut
)
private:
virtual int Exec(
    Guid% guidGroup, 
    unsigned int nCmdId, 
    unsigned int nCmdExcept, 
    IntPtr pIn, 
    IntPtr vOut
) sealed = IOleCommandTarget::Exec
private abstract Exec : 
        guidGroup:Guid byref * 
        nCmdId:uint32 * 
        nCmdExcept:uint32 * 
        pIn:IntPtr * 
        vOut:IntPtr -> int 
private override Exec : 
        guidGroup:Guid byref * 
        nCmdId:uint32 * 
        nCmdExcept:uint32 * 
        pIn:IntPtr * 
        vOut:IntPtr -> int 
JScript does not support explicit interface implementations.

Parameters

  • guidGroup
    Type: System.Guid%
    System.Guid guidGroup. The menu group. This implementation maps the group to CommandID.Guid.
  • nCmdId
    Type: System.UInt32
    System.UInt32 nCmdId. The ID code of the command. This implementation maps nCmdId to CommandID.ID.
  • nCmdExcept
    Type: System.UInt32
    System.UInt32 nCmdExcept. Count of command options. This implementation ignores this parameter.
  • pIn
    Type: System.IntPtr
    System.Object[] pIn. Actual command options. This implementation ignores this parameter.
  • vOut
    Type: System.IntPtr
    System.IntPtr vOut. Output data for the command. This implementation ignores this parameter.

Return Value

Type: System.Int32
An HRESULT code indicating the success or failure of the call. The following HRESULTs may be returned:

Value

Description

S_OK

The command was successfully invoked.

OLECMDERR_E_UNKNOWNGROUP

The group guid did not match the commandID’s Guid property for any command or verb.

OLECMDERR_E_NOTSUPPORTED

The group was found, but there is no command or verb with an ID that matches. This is also returned if the OleStatus property of a command that was found returns zero.

Implements

IOleCommandTarget.Exec(Guid%, UInt32, UInt32, IntPtr, IntPtr)

Remarks

This method is defined as a private interface implementation for IOleCommandTarget. To make use of it, a tool or document window generally implements IOleCommandTarget itself, and then forwards calls to the implementation contained in MenuCommandService. This implementation of Exec uses FindCommand to determine if a command exists, and invokes the command if it is disabled.

.NET Framework Security

See Also

Reference

OleMenuCommandService Class

OleMenuCommandService Members

Microsoft.VisualStudio.Shell Namespace