




























创建控件,其实就是创建一个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;
}
}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。