惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
G
Google Developers Blog
B
Blog
Engineering at Meta
Engineering at Meta
阮一峰的网络日志
阮一峰的网络日志
The Register - Security
The Register - Security
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 叶小钗
The Cloudflare Blog
The Hacker News
The Hacker News
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
雷峰网
雷峰网
F
Fortinet All Blogs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hackread – Cybersecurity News, Data Breaches, AI and More
酷 壳 – CoolShell
酷 壳 – CoolShell
Last Week in AI
Last Week in AI
T
Threat Research - Cisco Blogs
A
About on SuperTechFans
量子位
Recorded Future
Recorded Future
博客园 - 三生石上(FineUI控件)
H
Help Net Security
Help Net Security
Help Net Security
P
Palo Alto Networks Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Troy Hunt's Blog
W
WeLiveSecurity
V
Vulnerabilities – Threatpost
T
The Exploit Database - CXSecurity.com
Know Your Adversary
Know Your Adversary
Apple Machine Learning Research
Apple Machine Learning Research
Scott Helme
Scott Helme
N
News | PayPal Newsroom
AWS News Blog
AWS News Blog
D
DataBreaches.Net
Blog — PlanetScale
Blog — PlanetScale
MongoDB | Blog
MongoDB | Blog
B
Blog RSS Feed
腾讯CDC
J
Java Code Geeks
Microsoft Azure Blog
Microsoft Azure Blog
TaoSecurity Blog
TaoSecurity Blog
GbyAI
GbyAI
Y
Y Combinator Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
D
Docker

博客园 - IT-民工

Sqlsever Kill locked process Linked Server Dependencies C# PDF添加水印 Excel Vlookup多条件查询 , 列转行 Microsoft.Office.Interop.Excel error: 80070005 C# Linq 分页查询模板 SQLServer 查询 Excel ISO 纸张尺寸定义 检测SQLSERVER 连接 刷新SQLserver 视图 Sql Server 邮件日志 操作 常用连接 导出Excel Asp.net 多国语言-注意点 SqlServer 行列互转 SqlServer 备份数据库语法 SqlServer To SqlServer 建立 链接服务器 Linked Server sqlserver 根据内容,查询表和列名字 Sqlserver 2005 修改数据库默认排序
C# 编写ActiveX
IT-民工 · 2013-07-29 · via 博客园 - IT-民工

1. 新建 WindowFormControlLibrary

2. 修改 项目->右键属性->Application-> Assembly Information ->勾选 Make Assembly Com-Visible

3. 修改 项目->右键属性-> Build -> 勾选 Register for Com interop 

4. 控件cs界面, using System.Runtime.InteropServices 命名空间; 类名添加 GUID属性

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace MyActiveX2
{
    [Guid("07333C44-7CFD-3C64-A540-C476FE80EEF2")]
    public partial class demo : UserControl, IObjectSafety
    { .....

5. 继承IObjectSafety 接口

        #region IObjectSafety Members
        public void GetInterfacceSafyOptions(int riid, out int pdwSupportedOptions, out int pdwEnabledOptions)
        {
            pdwSupportedOptions = 1;
            pdwEnabledOptions = 2;
        }

        public void SetInterfaceSafetyOptions(int riid, int dwOptionsSetMask, int dwEnabledOptions)
        {
            //throw new NotImplementedException();
        }
        #endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace MyActiveX2
{

    [Guid("CB5BDC81-93C1-11CF-8F20-00805F2CD064"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    public interface IObjectSafety
    {
        void GetInterfacceSafyOptions(System.Int32 riid, out System.Int32 pdwSupportedOptions, out System.Int32 pdwEnabledOptions);
        void SetInterfaceSafetyOptions(System.Int32 riid, System.Int32 dwOptionsSetMask, System.Int32 dwEnabledOptions);
    }

}

6. 网页引用就可以了

   <object id="obj1" classid="clsid:07333C44-7CFD-3C64-A540-C476FE80EEF2" >      
    </object>

7. 安装程序

新建项目-> 安装项目 -> Appliction Folder -> 添加 项目的主输出,并设置Register属性为vsdrpCOM.