Click here to Skip to main content
15,861,125 members
Articles / Programming Languages / C++
Article

COM IDs & Registry keys in a nutshell

Rate me:
Please Sign up or sign in to vote.
4.87/5 (36 votes)
24 Jul 200111 min read 228.8K   119   10
An article about COM IDs and the Registry

Sub-sections list Sub-sections:

Some COM definitions Return to sub-sections list

COM Interface

When we are talking about Interface, we are as well talking about the separation between interface definition and implementation. Therefore, an interface defines a contract between the implementor and the user that physically prevents the user from accessing any of the details of the implementation.

You can look an Interface as a set of methods. This set of methods provides you services. You do not care about the implementation of these methods so long as you can use the services you need. COM interface refers to a predefined group of related functions that a COM class implements, but does not necessarily represent all the functions that the COM class supports.

One object-oriented programming (OOP) scholar says that we should concentrate upon the outside view of an object, and he calls this contract programming (B. Meyer, Object-Oriented Software Construction, 1988).

COM uses the concept of contract programming.

One of the rules in the COM world is that all COM interfaces must derive, either directly or indirectly, from the IUnknown interface.

COM class
or
Component Object Class (coclass)

(from the Platform SDK: COM / COM Class Objects and CLSIDs)

"A COM server is implemented as a COM class. A COM class is an implementation of a group of interfaces in code executed whenever you interact with a given object.

There is an important distinction between a C++ class and a COM class. In C++, a class is a type. A COM class is simply a definition of the object, and carries no type, although a C++ programmer might implement it using a C++ class. COM is designed to allow a class to be used by different applications, including applications written without knowledge of that particular class's existence. Therefore, class code for a given type of object exists either in a dynamic linked library (DLL) or in another application (EXE)."

COM object

A COM object is an instance of a COM Class at the runtime.

COM class object
or
Class Factory

(from the Platform SDK: COM / COM Class Objects and CLSIDs)

"The basic way to create an instance of a class (COM Class) is through a COM class object. This is simply an intermediate object that supports functions common to creating new instances (COM Object) of a given class (COM Class). Most class objects used to create objects from a CLSID support the IClassFactory interface, an interface that includes the important method CreateInstance. You implement an IClassFactory interface for each (COM) class of object that you offer to be instantiated.

Servers that support some other custom class factory interfaces are not required to support IClassFactory specifically. However, calls to activation functions other than CoGetClassObject (such as CoCreateInstanceEx) require that the server support IClassFactory."

The Platform SDK: Automation refers to a class factory as "An object that implements the IClassFactory interface, which allows it to create other objects of a specific class.". I will just add that it could be other class factory interfaces (not only the IClassFactory interface) such as the IClassFactory2 or a custom interface.

COM component

COM component refers to a binary module, such as a DLL or an Executable. After registering, a component will expose one or more COM Class Object (or Object Factory).

Type Library

Type libraries contain the specification (metadata) for one or more COM elements, including classes, interfaces, enumerations, and more. These files are stored in a standard binary format. A type library can be a stand-alone file with the .tlb filename extension, or it can be stored as a resource in an executable file, which can have a .ocx, .dll, or .exe file name extension.

COM IDs Return to sub-sections list

In COM world, you have to identify different pieces such as coclasses, interfaces, type libraries, applications, etc. These pieces must be unique in the world.
COM uses the Globally Unique IDentifier (GUID) to define these different IDs.
In an Interface Definition Language (IDL) file, you have to use the attribute uuid that stands for Universally Unique IDentifier. A UUID and a GUID are equivalent.
So, what is a GUID ? A GUID is a 128-bit number, usually represented in hexadecimal, which is guaranteed "to be unique across space and time". For example, the following number is a GUID:
{60B4140E-B0A7-4540-B744-7E1A944E8C78}
COM borrows this identify system to the Distributed Computing Environment (DCE) naming scheme. The DCE RPC system uses UUIDs.

The main COM IDs are:
  • LIBID: the Type Library ID, based on GUID.
  • APPID: the Application ID, based on GUID.
  • CLSID: the COM Class ID, based on GUID.
  • IID: the Interface ID, based on GUID.
  • PROGID: the Program ID, based on a text string.
In short, we can have:

COM IDs
Nota: this scheme is not complete, e.g. the Class factory is missing.

To obtain a GUID/UUID you can use:
  • the UUIDGEN.EXE found in the \TOOLs directory of the COM Toolkit (or "\Microsoft Visual Studio\Common\Tools").
  • the GUIDGEN.EXE found in the "\Microsoft Visual Studio\Common\Tools" directory.
  • the COM API function CoCreateGuid().

The Registry Return to sub-sections list

Before starting, here are some acronyms used in the Windows registry documentation and their meaning:
  • HKLM: the HKEY_LOCAL_MACHINE key. Information registered under this key might apply to all users on the local computer.
  • HKCR: the HKEY_CLASSES_ROOT key, a short cut for HKEY_LOCAL_MACHINE\Software\Classes.
  • HKCU: the HKEY_CURRENT_USER key.
Class registration and file extension informations are stored under the HKEY_LOCAL_MACHINE\Software\Classes key.
COM retrieves the information about COM Classes from the local Registry. With Windows 2000 there is now a global implementation repository called Active Directory. COM uses the registry as well to look for Interface properties and security-related configuration in order to manage the marshalling and distributed access.

All COM Classes related configuration information on the local workstation is stored in the following registry keys:
  • HKEY_CLASSES_ROOT, for backward compatibility.
  • HKEY_LOCAL_MACHINE\Software\Classes, Available on Windows NT 4.0 .
  • HKEY_CURRENT_USER\Software\Classes, Available on Windows 2000.
On Windows 2000 you can register COM class not only as the local machine level but also at the user level, and so you should be very careful as the HKCR is a merged view of HKLM\Software\Classes key and HKCU\Software\Classes key. This is due to the fact that in Windows 2000 class registration and file extension information are stored under both the HKLM key and the HKCU key.

HKEY_CLASSES_ROOT\CLSID\{GUID}
or
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{GUID} or (Windows 2000 only)
HKEY_CURRENT_USER\SOFTWARE\Classes\CLSID\{GUID}
Return to sub-sections list

A CLSID is a globally unique identifier that identifies a COM class object.

AppID node

Image 7

Image 8 HKEY_CLASSES_ROOT 
     |...
     Image 9 CLSID 
|...
Image 10 {<CLSID_value>} The CLSID_value is a 128-bit Globally Unique Identifier (GUID) that identifies the CLSID key
Image 11 @    String value
The human-readable name.
Image 12 AppID    String value
It is a 128-bit Globally Unique Identifier (GUID) that identifies the AppID key.
Image 13 AutoConvertTo  Automatic object class conversion
Image 14 @    String value
The class identifier (CLSID) of the object to which a given object or class of objects should be converted.
Image 15 AutoTreatAs  Assigns the TreatAs value
Image 16 @    String value
The CLSID that will automatically be assigned to the TreatAs entry.
Image 17 AuxUserType  Identifies object as a control
Image 18 2  ShortDisplayName
Image 19 @    String value
Specifies an application's short display name, used in menus, including pop-ups (e.g. "Chart").
Image 20 3  ApplicationName
Image 21 @    String value
Specifies an application name, used in the Results field of the Paste Special dialog box (e.g. "Super Graph 2001 Chart").
Image 22 Control  Identifies an object as an ActiveX Control
Image 23 @    String value
This optional entry is used by containers to fill in dialog boxes. The container uses this subkey to determine whether to include an object in a dialog box that displays ActiveX Controls.
Image 24 Conversion  Conversion used by the Convert dialog
Image 25 Readable   
Image 26 Main   
Image 27 @    String value
The file format an application can read (convert from).
Image 28 ReadWritable   
Image 29 Main   
Image 30 @    String value
The file format an application can read and write (activate as).
Image 31 DataFormats  Formats supported by applications
Image 32 DefaultIcon  Provides default icon information
Image 33 @    String value
Specifies the full path to the executable name of the object application and the resource index of the icon within the executable (e.g. "c:\toto\titi.exe,0").
Image 34 InprocHandler  Registers a 16-bit handler DLL
Image 35 @    String value
Specifies the custom handler used by the application.
Image 36 InprocHandler32  Registers a 32-bit handler DLL
Image 37 @    String value
Specifies the custom handler used by the application.
Image 38 InprocServer  Registers a 16-bit in-process server DLL
Image 39 @    String value
Specifies the path to the in-process server DLL.
Image 40 InprocServer32  Registers a 32-bit in-process server DLL
Image 41 @    String value
Specifies the path to the 32-bit in-process server.
Image 42 ThreadingModel    String value
Specifies the threading model of the apartment the server can run in.
In-process servers are loaded into an existing apartment and so do not call CoInitialize or CoInitializeEx; they must use the registry to specify an application's threading model.
Allowable values are:
ThreadingModel=Apartment. Single-threaded apartment.
ThreadingModel=Both. Single-threaded or multithreaded apartment.
ThreadingModel=Free. Multithreaded apartment.
ThreadingModel=Neutral. Neutral apartment (available in Windows 2000).
Image 43 Insertable  Indicates whether the object is insertable in COM applications.
Objects of this class should appear in the Insert Object dialog box's list box when used by COM container applications.
Image 44 @    String value
Specifies the path to the 32-bit in-process server.
Image 45 LocalServer  Full path to a 16-bit local server application
Image 46 @    String value
Specifies the full path to the local server, and can include command-line arguments.
Image 47 LocalServer32  Full path to a 32-bit local server application
Image 48 @    String value
Specifies the full path to the local server, and can include command-line arguments.
Image 49 MiscStatus  Specifies how to create and display an object
Image 50 ProgID  Programmatic identifier for a class
Image 51 @    String value
Associates a ProgID with a CLSID. Generally, the ProgID structure is like: <vendor>.<component>.<version>
and must:
  • Have no more than 39 characters.
  • Contain no punctuation (including underscores) except one or more periods.
  • Not start with a digit.
Image 52 ToolBoxBitmap32  Identifies the module name and resourdeID for a 16 x 16 bitmap to use for the face of a toolbar or toolbox button
Image 53 @    String value
Specifies the module name and the resourceID for the bitmap (e.g. "c:\toto\titi.dll,5").
Image 54 TreatAs  Specifies the CLSID of a class that can emulate the current class
Image 55 @    String value
CLSID of the Class that is to perform the emulation.
Emulation is the ability of one application to open and edit an object of a different class, while retaining the original format of the object.
Image 56 Verb  Verbs associated with an application
Image 57 Version  Version number of the control
Image 58 @    String value
The version number of the control.
The version number should match the version of the type library associated with the control.


HKEY_CLASSES_ROOT\AppID\{GUID}
or
HKEY_LOCAL_MACHINE\Software\Classes\AppID\{GUID}
Return to sub-sections list

The AppID registry key groups the configuration and security options for all coclasses exposed by a COM Sever and it is localised in the registry like that:

AppID node

Image 60

Image 61 HKEY_CLASSES_ROOT
     |...
     Image 62 AppID
|...
Image 63 {<AppID_value>} The AppID_value is a 128-bit Globally Unique Identifier (GUID) that identifies the AppID key
Image 64 @   String value
Generally the human-readable name of the component.
Image 65 AccessPermission   Binary value
Sets an ACL that determines access.
Image 66 ActivateAtStorage   String value
Configures the client to activate on the same system as persistent storage. Any value beginning with Y or y means that ActivageAtStorage should be used
Image 67 AuthenticationLevel    DWORD value
Sets the default authentication.Values are from 1 through 6, and correspond to the RPC_C_AUTHN_LEVEL_xxx constants.
Be aware that the AuthenticationLevel named value is supported only on Windows NT 4.0 SP4 and Windows 2000 as well as dcom95 1.1 .
Image 68 DllSurrogate   String value
Names the surrogate process used to load DLLs remotely or locally. To use the system-supplied generic surrogate process, set surrogate_path to an empty string or NULL.
Image 69 LaunchPermission   Binary value
Sets the ACL that determines who can launch the application.
Image 70 LocalService   String value
Configures the component to run as a Win32 service.
The LocalService named-value is used in preference to the LocalServer32 key for local and remote activation requests – if LocalService exists and refers to a valid service, the LocalServer32 key is ignored.
Image 71 LocalService32   String value
Configures the component to run as a Win32 service.
Image 72 RemoteServerName   String value
Names of the remote Server.
Image 73 RunAs   String value
Sets an application to run only as given user. It must either of the form username, domain\username, or the string "Interactive User". To establish a password for a RunAs class, you must use the DCOMCNFG administrative tool installed in the system directory.
Image 74 ServiceParameters   String value
Sets parameters to be passed to LocalService on invocation.

The keys referring to ACL values (AccessPermission and LaunchPermission) have to be set using an appropriate tool such as DCOMCNFG.EXE .

HKEY_CLASSES_ROOT\Interface\{GUID}
or
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\{GUID}
Return to sub-sections list

The Interface registry key registers new interfaces by associating an interface name with an Interface ID or IID and it is localised in the registry like that:

AppID node

Image 76

Image 77 HKEY_CLASSES_ROOT
     |...
     Image 78 Interface
|...
Image 79 {<IID_value>} The IID_value is a 128-bit Globally Unique Identifier (GUID) that identifies the Interface
Image 80 @   String value
Generally the human-readable name of the Interface.
Image 81 BaseInterface  Interface derived from
Image 82 @   String value
The IID (GUID) of the Interface derived from.
Image 83 NumMethods  Number of methods
Image 84 @   String value
The number of methods exposed by the Interface.
Image 85 ProsyStubCLSID  Maps IID to CLSID (16-bit DLLs)
Image 86 @   String value
Specifies the CLSID (GUID) to map the IID to.

If you add interfaces, you must use this entry to register them (16-bit systems) so that OLE can find the appropriate remoting code to establish interprocess communication.
Image 87 ProsyStubCLSID32  Maps IID to CLSID (32-bit DLLs)
Image 88 @   String value
Specifies the CLSID (GUID) to map the IID to.

This is a required entry since the IID-to-CLSID mapping may be different for 16- and 32-bit interfaces. The IID-to-CLSID mapping depends on the way the interface proxies are packaged into a set of proxy DLLs.

If you add interfaces, you must use this entry to register them (32-bit systems) so that OLE can find the appropriate remoting code to establish interprocess communication.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
France France
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionHow to interpret information under HKLM\software\classes\appid\{<GUID>} Pin
Shelke Amit11-Nov-14 0:13
Shelke Amit11-Nov-14 0:13 
GeneralMy vote of 5 Pin
ghvnd17-Jun-13 9:12
ghvnd17-Jun-13 9:12 
GeneralMy vote of 5 Pin
SolarCell11-Jan-12 10:13
SolarCell11-Jan-12 10:13 
GeneralMy vote of 5 Pin
Gophern Kwok3-Jan-12 23:48
Gophern Kwok3-Jan-12 23:48 
QuestionSet LaunchPermission Programatically Pin
DanielWehrle3-Apr-09 3:10
DanielWehrle3-Apr-09 3:10 
GeneralExcellent resource - thanks! Pin
Laughing John8-Apr-08 23:18
Laughing John8-Apr-08 23:18 
GeneralHKEY_CLASSES_ROOT "merged view" - thanks Pin
pg--az18-Feb-07 11:54
pg--az18-Feb-07 11:54 
GeneralRe: HKEY_CLASSES_ROOT &quot;merged view&quot; - thanks Pin
Polity4h19-Feb-07 7:14
Polity4h19-Feb-07 7:14 
Generalprogids in registry Pin
Arunava17-Mar-05 23:50
Arunava17-Mar-05 23:50 
QuestionHow to make Installation Program to load ATL Com Add-in(.dll) with MS Outlook ? Pin
Atif Bashir12-Aug-03 20:17
Atif Bashir12-Aug-03 20:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.