All the different kinds of OLE/COM server software--compound document server applications, Automation server applications, and OLE controls--must be registered with Windows so that OLE/COM client applications can use them. Until a server or control has been registered, there is no way for a client to find it.
Servers and controls typically register themselves. Registration involves the server or control entering its own COM Class ID into the Windows Registry. If a server or control implements more than one COM object, it must register the Class ID for each one.
The Class ID is recorded alongside the pathname to the server executable, or control OCX or DLL file. When a client application asks to connect to a COM object with a particular Class ID, the native Windows OLE/COM libraries consult the Registry to find the path to the server or control that implements the COM object in question, using the Class ID as a key.
Conventionally, you register server applications by calling them with the command-line argument /RegServer or -RegServer. For example:
ms-dos> my-server-app.exe /RegServer
The application recognizes the registration request, registers itself, and exits without doing anything else. Applications can also unregister themselves when they receive the command-line argument /UnregServer or -UnregServer.
OLE controls register themselves dynamically when they are invoked. You supply registration data (including Class IDs) to a macro initialize-ole-control (see page 338), which prepares the DLL/OCX into which the control is built for dynamic self-registration when a container invokes it. You can also register a control explicitly with the command regsvr32:
ms-dos> regsvr32 my-control.ocx
Server applications and controls must of course contain code that can perform registration. The Functional Developer OLE/COM API provides functions to help simplify the coding you need to do for self-registration.
Note: When you perform an explicit registration with either /RegServer, -RegServer, or regsvr32, the full pathname of the file is recorded in the registry. To move the file to a different folder, you must first unregister it, then move it, and then register it again at its new location.