IOleCommandTarget.Exec Method

Executes the specified command.

Namespace:  Microsoft.VisualStudio.OLE.Interop
Assembly:  Microsoft.VisualStudio.OLE.Interop (in Microsoft.VisualStudio.OLE.Interop.dll)


Function Exec ( _
    ByRef pguidCmdGroup As Guid, _
    nCmdID As UInteger, _
    nCmdexecopt As UInteger, _
    pvaIn As IntPtr, _
    pvaOut As IntPtr _
) As Integer
int Exec(
    ref Guid pguidCmdGroup,
    uint nCmdID,
    uint nCmdexecopt,
    IntPtr pvaIn,
    IntPtr pvaOut
int Exec(
    [InAttribute] Guid% pguidCmdGroup, 
    [InAttribute] unsigned int nCmdID, 
    [InAttribute] unsigned int nCmdexecopt, 
    [InAttribute] IntPtr pvaIn, 
    [InAttribute] IntPtr pvaOut
abstract Exec : 
        pguidCmdGroup:Guid byref * 
        nCmdID:uint32 * 
        nCmdexecopt:uint32 * 
        pvaIn:IntPtr * 
        pvaOut:IntPtr -> int 
function Exec(
    pguidCmdGroup : Guid, 
    nCmdID : uint, 
    nCmdexecopt : uint, 
    pvaIn : IntPtr, 
    pvaOut : IntPtr
) : int


  • pguidCmdGroup
    Type: System.Guid%
    The GUID of the command group.
  • nCmdexecopt
    Type: System.UInt32
    Specifies how the object should execute the command. Possible values are taken from the OLECMDEXECOPT and OLECMDID_WINDOWSTATE_FLAG enumerations.
  • pvaOut
    Type: System.IntPtr
    The output arguments of the command.

Return Value

Type: System.Int32
This method returns S_OK on success. Other possible return values include the following.

Return code



The pguidCmdGroup parameter is not null but does not specify a recognized command group.


The nCmdID parameter is not a valid command in the group identified by pguidCmdGroup.


The command identified by nCmdID is currently disabled and cannot be executed.


The caller has asked for help on the command identified by nCmdID, but no help is available.


The user canceled the execution of the command.


For information on the COM interface, see IOleCommandTarget::Exec

.NET Framework Security

See Also


IOleCommandTarget Interface

Microsoft.VisualStudio.OLE.Interop Namespace