Win32:注册ActiveX控件所需的注册表项? [英] Win32: Registry entries required to register an ActiveX control?

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

问题描述

我需要写调用DllRegisterServer时运行的代码。即有人呼叫时:

  regsvr32 myActiveX.ocx 

我试图找到所需的注册表项的确定列表(而不是只能通过注册表通过拼写来拼凑在一起)。



到目前为止,我的探险发现了:

  HKEY_CLASSES_ROOT 
\MyCoolLibrary.MyCoolControl
\Clsid
(default)={myClassId}
\CLSID
\ {myClassId}
\Control
\InprocServer32
(默认)=c:\foo\myActiveX.ocx
ThreadingModel =公寓
\MiscStatus
\1
(默认)= 205201
\ProgID
(默认)=MyCoolLibrary.MyCoolControl
\ToolboxBitmap32
(默认)=c:\foo\myActiveX.ocx,1
\TypeLib
(default)={myTypeLibraryGuid}
\Verb
\0
(默认)=属性,0,2
\Version
(default)=1.0
\TypeLib
\ {myTypeLibraryGuid}
\1.0
(默认)=MyCoolLibrary.MyCoolControl

现在,关注点:$ b​​ $ b - Control文件夹包含什么?它的存在是否表示控制?
- 205201的MiscStatus是什么? 205202会做什么?
- 什么是动词属性,0,2? 属性,0,0和属性,0,1在哪里?



换句话说,我在寻找文档。

解决方案

我知道到目前为止。 COM根据它的 clsid 创建一个对象。这是一个唯一标识该类的guid。

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

然后,该类用于创建对象。 COM现在需要知道哪个DLL是持有该COM对象。在我的特定情况下,暴露COM对象的服务器是一个DLL,并将正在进行。然后我们通过添加以下内容将COM指向进程内dll:

  HKEY_CLASSES_ROOT 
\Clsid
\ {AE8530CF-D204-4877-9CAB-F052BF1F661F}
\InprocServer32
(默认)=c:\foo\myActiveX.ocx

COM还需要知道COM服务器对象支持的线程模型。最简单,最常见的和本例中使用的是公寓线程模型:

  HKEY_CLASSES_ROOT 
\Clsid
\ {AE8530CF-D204-4877-9CAB-F052BF1F661F}
\InprocServer32
(默认)=c:\foo\myActiveX.ocx
ThreadingModel =Apartment

接下来是ProgID。这类似于如何使用DNS将友好名称转换为IP。在这里,我们将一个友好的名称MyCoolLibrary.MyCoolControl变成了丑陋的clsid {AE8530CF-D204-4877-9CAB-F052BF1F661F}

  HKEY_CLASSES_ROOT 
\Clsid
\ {AE8530CF-D204-4877-9CAB -F052BF1F661F}
\InprocServer32
(默认)=c:\foo\myActiveX.ocx
ThreadingModel =公寓
HKEY_CLASSES_ROOT
\ MyCoolLibrary.MyCoolControl
\Clsid
(默认)={AE8530CF-D204-4877-9CAB-F052BF1F661F}

现在有人可以要求

  MyCoolLibrary.MyCoolControl 



而COM可以将其转换为ClassID

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

一旦COM具有clasid然后可以在 HKCR\Clsid\ {AE8530CF-D204-4877-9CAB-F052BF1F661F} 下的注册表中查找真实信息。



为了有趣,ProgID被添加到Clsid部分,只是为了让人们可以知道这个类是什么:

  HKEY_CLASSES_ROOT 
\Clsid
\ {AE8530CF-D204-4877-9CAB-F052BF1F661F}
\InprocServer32
(默认值)=c: \\ foo\myActiveX.ocx
ThreadingModel =Apartment
\ProgID
(默认)=MyCoolLibrary.MyCoolControl
HKEY_CLASSES_ROOT
\MyCoolLibrary。 MyCoolControl
\Clsid
(默认)={AE8530CF-D204-4877-9CAB-F052BF1F661F}

接下来是类型库。这对于进程中的任何东西都是重要的,但是如果COM对象在另一个公寓中,则函数参数需要编组。 COM如果它有一个定义所有的类方法的类型库,它会自动为你。



clsid部分指向添加了TypeLib键的相应类型库:

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

有关此类型库的信息也存储在注册表中,但添加这些密钥是通过调用 RegisterTypeLib 来完成的。但它会为我们添加类似的键:

  HKEY_CLASSES_ROOT 
\Clsid
\ {AE8530CF -D204-4877-9CAB-F052BF1F661F}
\InprocServer32
(默认)=c:\foo\myActiveX.ocx
ThreadingModel =公寓
\\ \\ progID
(默认)=MyCoolLibrary.MyCoolControl
\TypeLib
(默认)={17A5A3D4-439C-4C2A-8AB4-749B7771CDE1}
HKEY_CLASSES_ROOT
\MyCoolLibrary.MyCoolControl
\Clsid
(默认)={AE8530CF-D204-4877-9CAB-F052BF1F661F}
HKEY_CLASSES_ROOT
\TypeLib
\ {AE8530CF-D204-4877-9CAB-F052BF1F661F}
\1.0
(默认)=我的酷ActiveX库
...



现在我们进入棘手的东西,需要希望使ActiveX控件工作。



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

  HKEY_CLASSES_ROOT 
\Clsid
\ {AE8530CF-D204-4877-9CAB-F052BF1F661F}
\可编程

此MSDN库页面表示关键字为控制,而不是可编程,并且没有可编程键。



但是这不会阻止一些ActiveX的使用控制,一些使用Programmable和一些使用两者。



我找不到任何提及任何其他要求。



那么,谁能找到一些确定的文档?


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:\foo\myActiveX.ocx"
            ThreadingModel = "Apartment"
         \MiscStatus
            \1
               (default) = 205201
         \ProgID
            (default) = "MyCoolLibrary.MyCoolControl"
         \ToolboxBitmap32
            (default) = "c:\foo\myActiveX.ocx,1"
         \TypeLib
            (default) = "{myTypeLibraryGuid}"
         \Verb
            \0
               (default) = "Properties,0,2"
         \Version
            (default) = "1.0"
   \TypeLib
      \{myTypeLibraryGuid}
         \1.0
            (default) = "MyCoolLibrary.MyCoolControl"

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.

解决方案

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}

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:\foo\myActiveX.ocx"

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:\foo\myActiveX.ocx"
            ThreadingModel = "Apartment"

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:\foo\myActiveX.ocx"
            ThreadingModel = "Apartment"
HKEY_CLASSES_ROOT
    \MyCoolLibrary.MyCoolControl
       \Clsid
           (default) = "{AE8530CF-D204-4877-9CAB-F052BF1F661F}"

Now someone can ask for

MyCoolLibrary.MyCoolControl

and COM can turn that into the ClassID

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

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

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:\foo\myActiveX.ocx"
            ThreadingModel = "Apartment"
         \ProgID
             (default) = "MyCoolLibrary.MyCoolControl"
HKEY_CLASSES_ROOT
    \MyCoolLibrary.MyCoolControl
       \Clsid
           (default) = "{AE8530CF-D204-4877-9CAB-F052BF1F661F}"

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.

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:\foo\myActiveX.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}"

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:\foo\myActiveX.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"
           ...

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

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

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

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控件所需的注册表项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆