今天开博了2007-7-16

开博没有太监的客。。。

 

利用.net创建安全COM控件

创建控件,其实就是创建一个dll,把他注册成COM  控件,并给它导入安全接口。
(安全是指在调用是不会弹出安全对话框)

using System;

using System.Runtime.InteropServices;

 

namespace openOffice

{

     /// <summary>

     /// IObjectSafety 的摘要说明。

     /// </summary>

     [Guid("CB5BDC81-93C1-11CF-8F20-00805F2CD064"),InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]

     public interface IObjectSafety

     {

         // methods

         void GetInterfacceSafyOptions(

              System.Int32 riid,

              out System.Int32 pdwSupportedOptions,

              out System.Int32 pdwEnabledOptions);

         void SetInterfaceSafetyOptions(

              System.Int32 riid,

              System.Int32 dwOptionsSetMask,

              System.Int32 dwEnabledOptions);     

     }

}

 

using System;

using System.Collections.Generic;

using System.Text;

using System.Windows.Forms;

using System.Runtime.InteropServices;

using Word = Microsoft.Office.Interop.Word;

using Excel = Microsoft.Office.Interop.Excel;

using OpenOffice.localhost;

using System.Net;

using System.IO;

 

namespace openOffice

{

    [Guid("B783512A-CA69-4b1e-97D7-1EC0FAEFC13B"), ProgId("openOffice.DmosClient")]

    public class DmosClient : IObjectSafety, IDmosClient

    {

        public void ShowMessage(string msg)

        {

            MessageBox.Show(msg);

        }

 

        #region IObjectSafety 成员

 

        public void GetInterfacceSafyOptions(Int32 riid, out Int32 pdwSupportedOptions, out Int32 pdwEnabledOptions)

        {

            // TODO:  添加WebCamControl.GetInterfacceSafyOptions 实现

            pdwSupportedOptions = CLsObjectSafety.INTERFACESAFE_FOR_UNTRUSTED_CALLER;

            pdwEnabledOptions = CLsObjectSafety.INTERFACESAFE_FOR_UNTRUSTED_DATA;

        }

 

        public void SetInterfaceSafetyOptions(Int32 riid, Int32 dwOptionsSetMask, Int32 dwEnabledOptions)

        {

            // TODO:  添加WebCamControl.SetInterfaceSafetyOptions 实现             

        }

 

        #endregion

 

    }

}

 

using System;

 

namespace openOffice

{

     /// <summary>

     /// CLsObjectSafety 的摘要说明。

     /// </summary>

     public class CLsObjectSafety

     {

         public const System.Int32 INTERFACESAFE_FOR_UNTRUSTED_CALLER = 0x00000001;

         public const System.Int32 INTERFACESAFE_FOR_UNTRUSTED_DATA = 0x00000002;

     }

}

posted on 2007-07-18 16:25  胡敏  阅读(684)  评论(0编辑  收藏  举报

导航