• 大小: 1.21MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-08-15
  • 语言: C/C++
  • 标签: ActiveX  控件  源码  

资源简介

使用C#开发ActiveX控件(含示例教程)源码 功能介绍: ActiveX控件以前也叫做OLE控件,它是微软IE支持的一种软件组件或对象,可以将其插入到Web页面中,实现在浏览器端执行动态程序功能,以增强浏览器端的动态处理能力。通常ActiveX控件都是用C++或VB语言开发,本文介绍另一种方式,在.NET Framework平台上,使用C#语言开发ActiveX控件。 虽然本文通篇都在讲如何使用C#语言开发ActiveX控件,但我并不极力推荐使用这种技术,因为该技术存在明显的局限,即需要浏览器端安装.NET Framework(版本取决于开发ActiveX控件使用的.NET Framework版本),该局限对于挑剔的互联网用户,几乎是不可接受的。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Text;
//www.51aspx.com
namespace CSharpActiveX
{
    public abstract class ActiveXControl : IobjectSafety
    {
        #region IobjectSafety 成员

        private const string _IID_IDispatch = “{00020400-0000-0000-C000-000000000046}“;
        private const string _IID_IDispatchEx = “{a6ef9860-c720-11d0-9337-00a0c90dcaa9}“;
        private const string _IID_IPersistStorage = “{0000010A-0000-0000-C000-000000000046}“;
        private const string _IID_IPersistStream = “{00000109-0000-0000-C000-000000000046}“;
        private const string _IID_IPersistPropertyBag = “{37D84F60-42CB-11CE-8135-00AA004BB851}“;

        private const int INTERFACESAFE_FOR_UNTRUSTED_CALLER = 0x00000001;
        private const int INTERFACESAFE_FOR_UNTRUSTED_DATA = 0x00000002;
        private const int S_OK = 0;
        private const int E_FAIL = unchecked((int)0x80004005);
        private const int E_NOINTERFACE = unchecked((int)0x80004002);

        private bool _fSafeForscripting = true;
        private bool _fSafeForInitializing = true;


        public int GetInterfaceSafetyOptions(ref Guid riid ref int pdwSupportedOptions ref int pdwEnabledOptions)
        {
            int Rslt = E_FAIL;

            string strGUID = riid.ToString(“B“);
            pdwSupportedOptions = INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA;
            switch (strGUID)
            {
                case _IID_IDispatch:
                case _IID_IDispatchEx:
                    Rslt = S_OK;
                    pdwEnabledOptions = 0;
                    if (_fSafeForscripting == true)
                        pdwEnabledOptions = INTERFACESAFE_FOR_UNTRUSTED_CALLER;
                    break;
                case _IID_IPersistStorage:
                case _IID_IPersistStream:
                case _IID_IPersistPropertyBag:
                    Rslt = S_OK;
                    pdwEnabledOptions = 0;
                    if (_fSafeForInitializing == true)
                        pdwEnabledOptions = INTERFACESAFE_FOR_UNTRUSTED_DATA;
                    break;
                default:
                    Rslt = E_NOINTERFACE;
                    break;
            }

            return Rslt;
        }

        public int SetInterfaceSafetyOptions(ref Guid riid int dwOptionSetMask int dwEnabledOptions)
        {
            int Rslt = E_FAIL;

            string strGUID = riid.ToString(“B“);
            switch (strGUID)
            {
                case _IID_IDispatch:
                case _IID_IDispatchEx:
                    if (((dwEnabledOptions & dwOptionSetMask) == INTERFACESAFE_FOR_UNTRUSTED_CALLER) &&
                            (_fSafeForscripting == true))
                        Rslt = S_OK;
                    break;
                case _IID_IPersistStorage:
                case _IID_IPersistStream:
                case _IID_IPersistP

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2013-06-28 12:55  ActiveXTutorials_46a0bf76-3a8d-4ed3-8fbc-f0d196d6dbba\
     目录           0  2013-06-26 09:15  ActiveXTutorials_46a0bf76-3a8d-4ed3-8fbc-f0d196d6dbba\CAB\
     文件         873  2013-06-23 22:54  ActiveXTutorials_46a0bf76-3a8d-4ed3-8fbc-f0d196d6dbba\CAB\Apollo.cer
     文件        2590  2013-06-22 21:38  ActiveXTutorials_46a0bf76-3a8d-4ed3-8fbc-f0d196d6dbba\CAB\Apollo.pfx
     文件         306  2013-06-22 15:29  ActiveXTutorials_46a0bf76-3a8d-4ed3-8fbc-f0d196d6dbba\CAB\cab.ddf
     文件      155673  2013-06-24 23:21  ActiveXTutorials_46a0bf76-3a8d-4ed3-8fbc-f0d196d6dbba\CAB\CSharpActiveX.CAB
     文件      441344  2013-06-24 23:19  ActiveXTutorials_46a0bf76-3a8d-4ed3-8fbc-f0d196d6dbba\CAB\CSharpActiveX.msi
     文件         143  2013-06-23 23:21  ActiveXTutorials_46a0bf76-3a8d-4ed3-8fbc-f0d196d6dbba\CAB\installer.inf
     文件          62  2013-06-23 16:17  ActiveXTutorials_46a0bf76-3a8d-4ed3-8fbc-f0d196d6dbba\CAB\makecab.bat
     文件       57344  2012-08-02 20:14  ActiveXTutorials_46a0bf76-3a8d-4ed3-8fbc-f0d196d6dbba\CAB\makecab.exe
     文件         121  2013-06-23 16:09  ActiveXTutorials_46a0bf76-3a8d-4ed3-8fbc-f0d196d6dbba\CAB\makecabsigned.bat
     文件      237392  2010-05-04 13:14  ActiveXTutorials_46a0bf76-3a8d-4ed3-8fbc-f0d196d6dbba\CAB\signtool.exe
     文件         433  2013-06-24 23:19  ActiveXTutorials_46a0bf76-3a8d-4ed3-8fbc-f0d196d6dbba\CAB\test.htm
     目录           0  2013-06-26 09:15  ActiveXTutorials_46a0bf76-3a8d-4ed3-8fbc-f0d196d6dbba\CSharpActiveX\
     目录           0  2013-06-26 09:15  ActiveXTutorials_46a0bf76-3a8d-4ed3-8fbc-f0d196d6dbba\CSharpActiveX.Setup\
     文件       31754  2013-06-24 23:19  ActiveXTutorials_46a0bf76-3a8d-4ed3-8fbc-f0d196d6dbba\CSharpActiveX.Setup\CSharpActiveX.Setup.vdproj
     目录           0  2013-06-26 09:28  ActiveXTutorials_46a0bf76-3a8d-4ed3-8fbc-f0d196d6dbba\CSharpActiveX.Setup\Debug\
     目录           0  2013-06-26 09:28  ActiveXTutorials_46a0bf76-3a8d-4ed3-8fbc-f0d196d6dbba\CSharpActiveX.Setup\Release\
     文件        1778  2013-06-24 23:00  ActiveXTutorials_46a0bf76-3a8d-4ed3-8fbc-f0d196d6dbba\CSharpActiveX.sln
     文件        3432  2013-06-26 09:26  ActiveXTutorials_46a0bf76-3a8d-4ed3-8fbc-f0d196d6dbba\CSharpActiveX\ActiveXControl.cs
     目录           0  2013-06-26 09:15  ActiveXTutorials_46a0bf76-3a8d-4ed3-8fbc-f0d196d6dbba\CSharpActiveX\bin\
     目录           0  2013-06-26 09:15  ActiveXTutorials_46a0bf76-3a8d-4ed3-8fbc-f0d196d6dbba\CSharpActiveX\bin\Debug\
     文件        7168  2013-06-24 23:19  ActiveXTutorials_46a0bf76-3a8d-4ed3-8fbc-f0d196d6dbba\CSharpActiveX\bin\Debug\CSharpActiveX.dll
     文件       13824  2013-06-24 23:19  ActiveXTutorials_46a0bf76-3a8d-4ed3-8fbc-f0d196d6dbba\CSharpActiveX\bin\Debug\CSharpActiveX.pdb
     目录           0  2013-06-26 09:16  ActiveXTutorials_46a0bf76-3a8d-4ed3-8fbc-f0d196d6dbba\CSharpActiveX\bin\Release\
     文件        7168  2013-06-26 09:27  ActiveXTutorials_46a0bf76-3a8d-4ed3-8fbc-f0d196d6dbba\CSharpActiveX\bin\Release\CSharpActiveX.dll
     文件       15872  2013-06-26 09:27  ActiveXTutorials_46a0bf76-3a8d-4ed3-8fbc-f0d196d6dbba\CSharpActiveX\bin\Release\CSharpActiveX.pdb
     文件        2263  2013-06-24 23:00  ActiveXTutorials_46a0bf76-3a8d-4ed3-8fbc-f0d196d6dbba\CSharpActiveX\CSharpActiveX.csproj
     文件         717  2013-06-26 09:27  ActiveXTutorials_46a0bf76-3a8d-4ed3-8fbc-f0d196d6dbba\CSharpActiveX\IobjectSafety.cs
     文件         826  2013-06-26 09:26  ActiveXTutorials_46a0bf76-3a8d-4ed3-8fbc-f0d196d6dbba\CSharpActiveX\MacActiveX.cs
     目录           0  2013-06-26 09:15  ActiveXTutorials_46a0bf76-3a8d-4ed3-8fbc-f0d196d6dbba\CSharpActiveX\obj\
............此处省略16个文件信息

评论

共有 条评论