IOleCommandTarget (Interfaces)
Last changed: -74.62.121.50

.
Summary
TODO - a short description

C# Definition:

[ComImport,

Guid("b722bccb-4e68-101b-a2bc-00aa00404770"),

InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]

public interface IOleCommandTarget

{

    //IMPORTANT: The order of the methods is critical here. You
    //perform early binding in most cases, so the order of the methods
    //here MUST match the order of their vtable layout (which is determined
    //by their layout in IDL). The interop calls key off the vtable
    //ordering, not the symbolic names. Therefore, if you switched these
    //method declarations and tried to call the Exec method on an
    //IOleCommandTarget interface from your application, it would
    //translate into a call to the QueryStatus method instead.
    void QueryStatus(
        ref Guid pguidCmdGroup,
        UInt32 cCmds,
        [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] OLECMD[] prgCmds,
        ref OLECMDTEXT CmdText);
    void Exec(
        ref Guid pguidCmdGroup,
        uint nCmdId,
        uint nCmdExecOpt,
        ref object pvaIn,
        ref object pvaOut);

}

VB Definition:

<ComImport> _
<Guid("TODO")> _
'TODO: Insert <InterfaceType(ComInterfaceType.InterfaceIsIUnknown)> _ if this doesn't derive from IDispatch
Interface IOleCommandTarget
   TODO
End Interface

User-Defined Types:

None.

Notes:

None.

Documentation

The above didn't work as is in C#. I looked on other sites and found this declaration which works for me (at least with Exec function) :

C# Definition:

    [StructLayout(LayoutKind.Sequential)]
    public struct OLECMD
    {
        public UInt32 cmdID;
        public UInt64 cmdf;
    }

    [StructLayout(LayoutKind.Sequential)]
    public struct OLECMDTEXT
    {
        public UInt32 cmdtextf;
        public UInt32 cwActual;
        public UInt32 cwBuf;
        public char rgwz;
    }

    [ComImport, Guid("b722bccb-4e68-101b-a2bc-00aa00404770"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    public interface IOleCommandTarget
    {

        //IMPORTANT: The order of the methods is critical here. You
        //perform early binding in most cases, so the order of the methods
        //here MUST match the order of their vtable layout (which is determined
        //by their layout in IDL). The interop calls key off the vtable
        //ordering, not the symbolic names. Therefore, if you switched these
        //method declarations and tried to call the Exec method on an
        //IOleCommandTarget interface from your application, it would
        //translate into a call to the QueryStatus method instead.
        [PreserveSig()]
        int QueryStatus([In, MarshalAs(UnmanagedType.Struct)] ref Guid pguidCmdGroup, [MarshalAs(UnmanagedType.U4)] int cCmds, [In, Out]IntPtr prgCmds, [In, Out] IntPtr pCmdText);

        [PreserveSig()]
        int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdExecOpt, object[] pvaIn, [In, Out, MarshalAs(UnmanagedType.LPArray)] object[] pvaOut);
    }