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

推荐订阅源

WordPress大学
WordPress大学
J
Java Code Geeks
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
腾讯CDC
IT之家
IT之家
罗磊的独立博客
酷 壳 – CoolShell
酷 壳 – CoolShell
U
Unit 42
爱范儿
爱范儿
博客园 - 聂微东
F
Fortinet All Blogs
V
Visual Studio Blog
Blog — PlanetScale
Blog — PlanetScale
G
Google Developers Blog
aimingoo的专栏
aimingoo的专栏
L
LangChain Blog
雷峰网
雷峰网
B
Blog RSS Feed
宝玉的分享
宝玉的分享
T
Tailwind CSS Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Engineering at Meta
Engineering at Meta
H
Hackread – Cybersecurity News, Data Breaches, AI and More

博客园 - Rain@sz

C#多线程编程(转) 调用webservice类(转) webService动态编译(编译在内存中,不会有权限问题) 什么是AOP? (摘) 阿里巴巴信息抓取器 脏读、不可重复读和虚读。(数据库)摘 SPS中模拟登陆 sql server 2005分页存储过程和sql server 2000分页存储过程(摘) net的辅助工具 ajax基本函数--js Memento Pattern(备忘录模式) Interpreter Pattern(解释器模式) State Pattern(状态模式) Mediator Pattern(中介者模式) 动态调用Webservice(摘) 分页--页脚控件 RSS 标准 DP-還未添加 DP-职责链模式(Chain of Responsibility)
c#写Activex控件(.Net 2.0)
Rain@sz · 2008-12-03 · via 博客园 - Rain@sz

1、继成一个IObjectSafety.cs,接口代码如下,功能是修改ie安全性
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.ComponentModel;

namespace activex
{
    [
        Serializable,
        ComVisible(true)
    ]
    public enum ObjectSafetyOptions
    {
        INTERFACESAFE_FOR_UNTRUSTED_CALLER = 0x00000001,
        INTERFACESAFE_FOR_UNTRUSTED_DATA = 0x00000002,
        INTERFACE_USES_DISPEX = 0x00000004,
        INTERFACE_USES_SECURITY_MANAGER = 0x00000008
    };

    //
    // MS IObjectSafety Interface definition
    //
    [
        ComImport(),
        Guid("CB5BDC81-93C1-11CF-8F20-00805F2CD064"),
        InterfaceType(ComInterfaceType.InterfaceIsIUnknown)
    ]
    public interface IObjectSafety
    {
        [PreserveSig]
        long GetInterfaceSafetyOptions(ref Guid iid, out int pdwSupportedOptions, out int pdwEnabledOptions);

        [PreserveSig]
        long SetInterfaceSafetyOptions(ref Guid iid, int dwOptionSetMask, int dwEnabledOptions);
    };
}

2、新建一个windows控件项目
      修改该控件类的Attribute,项目属性勾上为Com  Interop注册。
[
        Guid("627AD403-FA50-4a08-B875-770520865DD6"),
        ComVisible(true)
]

   控件中实现接口代码

   #region IObjectSafety 成员

        private ObjectSafetyOptions m_options =
            ObjectSafetyOptions.INTERFACESAFE_FOR_UNTRUSTED_CALLER |
            ObjectSafetyOptions.INTERFACESAFE_FOR_UNTRUSTED_DATA;

        public long GetInterfaceSafetyOptions(ref Guid iid, out int pdwSupportedOptions, out int pdwEnabledOptions)
        {
            pdwSupportedOptions = (int)m_options;
            pdwEnabledOptions = (int)m_options;
            return 0;
        }

        public long SetInterfaceSafetyOptions(ref Guid iid, int dwOptionSetMask, int dwEnabledOptions)
        {
            return 0;
        }

        #endregion

3、增加html访问代码,codebase为安装Activex控件的Cab包地址,也可以建一安装项目,来让客户下载安装。
<object id="id"
         classid="clsid:627AD403-FA50-4a08-B875-770520865DD6" Width="640" Height="360" codebase="hello.cab">
</object>