控件代码(项目->生成:勾选为COM互操作注册):
[ComImport, GuidAttribute("CB5BDC81-93C1-11CF-8F20-00805F2CD064")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
public interface IObjectSafety
{
[PreserveSig]
int GetInterfaceSafetyOptions(ref Guid riid, [MarshalAs(UnmanagedType.U4)] ref int pdwSupportedOptions, [MarshalAs(UnmanagedType.U4)] ref int pdwEnabledOptions);
[PreserveSig]
int SetInterfaceSafetyOptions(ref Guid riid, [MarshalAs(UnmanagedType.U4)] int dwOptionSetMask, [MarshalAs(UnmanagedType.U4)] int dwEnabledOptions);
}
public delegate void MessageHander(string msg);
[ComVisible(true)]//这个不能少
[Guid("C37124B1-8013-44C1-B8B4-9672B2AA175F")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface IActiveXEvents
{

本文介绍如何使用C#创建ActiveX控件,并实现与JavaScript的互调用。通过设置COM互操作注册,确保控件能在网页中正确使用。详细探讨了C#接口、函数和数据类型在交互过程中的应用。

862

被折叠的 条评论
为什么被折叠?



