本文介绍了Win32:注册 ActiveX 控件所需的注册表项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要编写调用 DllRegisterServer 时运行的代码.即当有人打电话时:

i need write the code that runs when DllRegisterServer is called. i.e. when someone calls:

regsvr32 myActiveX.ocx

我正在尝试找到所需注册表项的最终列表(而不仅仅是我可以通过拼写注册表拼凑出来的内容).

i'm trying to find the definitive list of required registry entries (rather than just what i can cobble together by spellunking through the registry).

到目前为止,我的探险队已经找到了:

So far my expeditions have found:

HKEY_CLASSES_ROOT
   MyCoolLibrary.MyCoolControl
      Clsid
         (default) = "{myClassId}"
   CLSID
      {myClassId}
         Control
         InprocServer32
            (default) = "c:foomyActiveX.ocx"
            ThreadingModel = "Apartment"
         MiscStatus
            1
               (default) = 205201
         ProgID
            (default) = "MyCoolLibrary.MyCoolControl"
         ToolboxBitmap32
            (default) = "c:foomyActiveX.ocx,1"
         TypeLib
            (default) = "{myTypeLibraryGuid}"
         Verb
            
               (default) = "Properties,0,2"
         Version
            (default) = "1.0"
   TypeLib
      {myTypeLibraryGuid}
         1.0
            (default) = "MyCoolLibrary.MyCoolControl"

现在,担忧:- 控制文件夹包含什么?它的存在是否表明控制?- 205201 的 MiscStatus 有什么作用?205202 会做什么呢?- 动词Properties,0,2"是什么?Properties,0,0"和Properties,0,1"在哪里?

Now, the concerns: - what does the Control folder contain? Is it's presence indicate a control? - what's a MiscStatus of 205201 do? What would 205202 do instead? - What's the verb "Properties,0,2"? Where's "Properties,0,0" and "Properties,0,1"?

换句话说,我正在寻找文档.

In other words, i'm looking for the docs.

推荐答案

到目前为止我所知道的.COM 基于它的clsid 创建一个对象.这是一个唯一标识该类的指南.

What i know so far. COM creates an object based on it's clsid. This is a guid that uniquely identifies that class.

HKEY_CLASSES_ROOT
   Clsid
      {AE8530CF-D204-4877-9CAB-F052BF1F661F}

然后使用该类来创建对象.COM 现在需要知道保存该 COM 对象的 DLL 在哪里.在我的特定情况下,公开 COM 对象的服务器"是一个 DLL,并且将处于进程中".然后,我们通过添加将 COM 指向该进程内"dll:

That class is then used to create objects. COM now needs to know where the DLL is that holds that COM Object. In my particular case, the "server" that exposes the COM object is a DLL, and will be "in process". We then point COM to that "in-process" dll by adding:

HKEY_CLASSES_ROOT
   Clsid
      {AE8530CF-D204-4877-9CAB-F052BF1F661F}
         InprocServer32
            (default) = "c:foomyActiveX.ocx"

COM 还需要知道 COM 服务器对象支持的线程模型.本例中使用的最简单、最常见的一种是Apartment"线程模型:

COM also needs to know the threading model that the COM server object supports. The simplest, most common, and the one used in this example is the "Apartment" threading model:

HKEY_CLASSES_ROOT
   Clsid
      {AE8530CF-D204-4877-9CAB-F052BF1F661F}
         InprocServer32
            (default) = "c:foomyActiveX.ocx"
            ThreadingModel = "Apartment"

接下来是 ProgID.这类似于使用 DNS 将友好名称转换为 IP 的方式.这里我们把一个好听的名字"MyCoolLibrary.MyCoolControl"变成丑陋的clsid "{AE8530CF-D204-4877-9CAB-F052BF1F661F}"

Next is the ProgID. This is similar to how DNS is used to turn a friendly name into an IP. Here we turn a friendly name "MyCoolLibrary.MyCoolControl" into the ugly clsid "{AE8530CF-D204-4877-9CAB-F052BF1F661F}"

HKEY_CLASSES_ROOT
   Clsid
      {AE8530CF-D204-4877-9CAB-F052BF1F661F}
         InprocServer32
            (default) = "c:foomyActiveX.ocx"
            ThreadingModel = "Apartment"
HKEY_CLASSES_ROOT
    MyCoolLibrary.MyCoolControl
       Clsid
           (default) = "{AE8530CF-D204-4877-9CAB-F052BF1F661F}"

现在有人可以要求了

MyCoolLibrary.MyCoolControl

COM 可以把它变成 ClassID

and COM can turn that into the ClassID

{AE8530CF-D204-4877-9CAB-F052BF1F661F}

一旦 COM 有了 clasid,它就可以在 HKCRClsid{AE8530CF-D204-4877-9CAB-F052BF1F661F} 下的注册表中查找真实信息.

Once COM has the clasid, it can then look in the registry under HKCRClsid{AE8530CF-D204-4877-9CAB-F052BF1F661F} to find the real information.

为了好玩,将 ProgID 添加到 Clsid 部分,以便人们了解这个类是什么:

For fun, the ProgID is added to the Clsid section, just so people can have some idea what this class is:

HKEY_CLASSES_ROOT
   Clsid
      {AE8530CF-D204-4877-9CAB-F052BF1F661F}
         InprocServer32
            (default) = "c:foomyActiveX.ocx"
            ThreadingModel = "Apartment"
         ProgID
             (default) = "MyCoolLibrary.MyCoolControl"
HKEY_CLASSES_ROOT
    MyCoolLibrary.MyCoolControl
       Clsid
           (default) = "{AE8530CF-D204-4877-9CAB-F052BF1F661F}"

接下来是类型库.这对于进程中的任何事情都很重要,但如果 COM 对象在另一个公寓"中,则需要编组函数参数.如果 COM 具有定义所有类方法的类型库,它会自动为您执行此操作.

Next is the type library. This is mostly unimportant for anything in-process, but if the COM object is in another "apartment", then function parameters need to be marshalled. COM does this automatically for you if it has a type library that defines all the classes methods.

clsid 部分通过添加一个 TypeLib 键指向适当的类型库:

The clsid section is pointed to the appropriate type library with the addition of a TypeLib key:

HKEY_CLASSES_ROOT
   Clsid
      {AE8530CF-D204-4877-9CAB-F052BF1F661F}
         InprocServer32
            (default) = "c:foomyActiveX.ocx"
            ThreadingModel = "Apartment"
         ProgID
             (default) = "MyCoolLibrary.MyCoolControl"
         TypeLib
             (default) = "{17A5A3D4-439C-4C2A-8AB4-749B7771CDE1}"
HKEY_CLASSES_ROOT
    MyCoolLibrary.MyCoolControl
       Clsid
           (default) = "{AE8530CF-D204-4877-9CAB-F052BF1F661F}"

有关此类型库的信息也存储在注册表中,但添加这些键是通过调用 RegisterTypeLib.但它会为我们添加类似于以下内容的键:

Information about this type library is also stored in the registry, but adding these keys is done for us with a call to RegisterTypeLib. But it will add keys for us similar to:

HKEY_CLASSES_ROOT
   Clsid
      {AE8530CF-D204-4877-9CAB-F052BF1F661F}
         InprocServer32
            (default) = "c:foomyActiveX.ocx"
            ThreadingModel = "Apartment"
         ProgID
             (default) = "MyCoolLibrary.MyCoolControl"
         TypeLib
             (default) = "{17A5A3D4-439C-4C2A-8AB4-749B7771CDE1}"
HKEY_CLASSES_ROOT
    MyCoolLibrary.MyCoolControl
       Clsid
           (default) = "{AE8530CF-D204-4877-9CAB-F052BF1F661F}"
HKEY_CLASSES_ROOT
    TypeLib
        {AE8530CF-D204-4877-9CAB-F052BF1F661F}
           1.0
              (default) = "My Cool ActiveX Library"
           ...

现在我们进入棘手的问题,希望使 ActiveX 控件工作所需的东西.

Now we get into the tricky stuff, stuff that is needed to hopefully make an ActiveX control work.

一篇 MSDN 文章指出您必须添加一个虚拟可编程键,表明它是一个 ActiveX 控件:

An MSDN article states that you must add a dummy Programmable key to indicate that it is an ActiveX control:

HKEY_CLASSES_ROOT
   Clsid
      {AE8530CF-D204-4877-9CAB-F052BF1F661F}
         Programmable

但是 这个 MSDN 库页面 说关键字是 Control,而不是 Programmable - 并且没有 Programmable 键.

But this MSDN Library page says the keyword is Control, and not Programmable - and there is no Programmable key.

但这并不能阻止一些 ActiveX 使用 Control,一些使用 Programmable,还有一些同时使用.

But that doesn't stop some ActiveX's from using Control, some using Programmable, and some using both.

我找不到任何提及其他需要的内容.

i cannot find anything mentioning anything else being required.

那么,任何人都可以找到一些权威的文档吗?

So, can anyone find some definitive documentation?

这篇关于Win32:注册 ActiveX 控件所需的注册表项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 07:42