activex开发有多种方式,可以是用MFC C++, C#,
以C# windows窗体控件库(.NET Framework)
新建IObjectSafety.cs文件
using System;
using System.Runtime.InteropServices;
namespace ActiveXDemo
{
[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);
}
}
修改UserControl.cs文件
using System;
using System.Runtime.InteropServices;
namespace ActiveXDemo
{
[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);
}
}
然后,修改Guid 改为自己新建的,点击工具->创建Guid
添加 安装包程序
VS2017 installproject 安装包
参考: http://www.cnblogs.com/li-peng/p/3455247.html
http://jiang.jonvie.com/post/2017/07/22/42c02ee7e97012f5
html页面设置
<object classid="clsid:CB5BDC81-93C1-11CF-8F20-00805F2CD064"></object>
//
<object type="application/x-testactive"></object>
设置 注册表
HKEY_LOCAL_MACHINE
SOFTWARE
Classes
MIME
Database
Content-Type
application/x-testactive
设置键值
CLSID {CB5BDC81-93C1-11CF-8F20-00805F2CD064}