Developing COM Components Using VC-ATL (2-3)

xiaoxiao2021-03-06  38

COM object registration role

If the COM component is loaded with file names and the component location or name changes, the client application will not access the component. File Names cannot provide different component versions on a system, thus causing a variety of product conflicts between different vendors.

COM handles this problem by using the location of the COM component in the system registry with the identifier ID. The ID of the COM component must be guaranteed to be unique to avoid conflicts with different products, and customers can access components without knowing the physical location of the component, which is the so-called component to the customer's transparency.

The COM class is registered under the HKEY_CLASES_ROOT / CLSID primary key. For each CLSID primary key, there is a subkey InprocServer32, the default value of this subkey is the file name of the DLL.

Components can be registered using the RegSver32 program. This program provides components entering the registry.

The DLL file can be registered using the following command:

Regsver32

In order to register an exe file, the command syntax is:

/ RegServer

The registration file read by the registration COM component is Mycom.RGS

In this example, the structure of the registry is (red is CLSID, green is IID, blue is libid)

HKEY_CLASS_ROOT / CLSID / {Feb7BDEF-FB6F-446B-BE31-DF0A3AD391BA}

Default Mycom Class

/ InprocServer32

Default c: /myproj/debug/myproj.dll

Apartment ThreadingModel

/ Progid

Default myproj.mycom.1

/ Programable

/ Typelib

Default {FE651184-11DE-4D01-BD69-B07DDFA12D0C}

/ VersionIndependentProgid

Default myproj.mycom

HKEY_CLASS_ROOT / MyProj.mycom

/ CLSID

Default {FEB7BDEF-FB6F-446B-BE31-DF0A3AD391BA}

/ Curver

Default myproj.mycom.1

HKEY_CLASS_ROOT / MyProj.mycom.1

/ CLSID

Default {FEB7BDEF-FB6F-446B-BE31-DF0A3AD391BA}

HKEY_CLASS_ROOT / Interface / {65460F9C-3BAB-4055-885A-8ED59F5FA9B0}

Default Imycom

/ Proxystubclsid

/ Proxystubclsid32

/ Typelib

Default {FE651184-11DE-4D01-BD69-B07DDFA12D0C}

Version 1.0

HKEY_CLASS_ROOT / TYPELIB / {FE651184-11DE-4D01-BD69-B07DDFA12D0C}

/1.0

Default MyProj 1.0 Type Library

/ 1.0/0

/ 1.0/0/win32

Default c: /myproj/debug/myproj.dll

/1.0/flags

/ 1.0/helpdir

Default C: / myproj / debug /

Author Blog:

http://blog.9cbs.net/callzjy/

转载请注明原文地址:https://www.9cbs.com/read-77828.html

New Post(0)