zoukankan      html  css  js  c++  java
  • c#实现IOleCommandTarget接口(原闯)

    using System;
    using System.Runtime.InteropServices;
    namespace d4htmlinterface
    {
        
    /// <summary>
        
    /// Class1 的摘要说明。
        
    /// </summary>

        public class htmlinterface
        
    {
            
    public htmlinterface()
            
    {
                
    //
                
    // TODO: 在此处添加构造函数逻辑
                
    //
            }

            [StructLayout(LayoutKind.Sequential,CharSet
    =CharSet.Unicode)]
                
    public struct OLECMDTEXT
            
    {
                
    public uint cmdtextf;
                
    public uint cwActual;
                
    public uint cwBuf;
                [MarshalAs(UnmanagedType.ByValTStr,SizeConst
    =100)]public char rgwz;
            }


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


            
    // Interop definition for IOleCommandTarget.
            [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);
            }

        }

    }

  • 相关阅读:
    无法添加数据库未能加载文件或程序集“Microsoft.SqlServer.Management.Sdk.Sfc, Version=10.0.0.0, Culture=neutral,PublicKeyToken=89845dcd8080c
    转载:自己制作Visual Studio项目模板(以原有项目为模版) VS—项目模板丢失的解决方案
    设计一个高效的缓存管理服务 C#
    Visual Studio 30个快捷键2009年05月22日
    Everything 中文绿色版
    Visual studio 打包
    远程桌面连接超出最大连接数的3种解决办法
    [Cache 学习] Cache.Insert 与 Cache.Add 区别
    三层架构之我见 —— 不同于您见过的三层架构。
    基于IIS发布你的WCF Service。
  • 原文地址:https://www.cnblogs.com/alice/p/188615.html
Copyright © 2011-2022 走看看