Registering a COM Object

From RAD Studio
Jump to: navigation, search

Go Up to Creating Simple COM Servers Index


You can register your server object as an in-process or an out-of-process server. For more information on the server types, see In-process, Out-of-process, and Remote Servers.

Note: The IDE, being a 32-bit process, cannot register 64-bit in-proc/DLL servers (32-bit processes cannot load 64-bit DLLs). To register 64-bit in-proc servers, you must use the 64-bit version of TRegSvr.exe, located in $(BDS)\bin64\TRegSvr.exe.

Managing Registry Entries

Registering a COM object adds an entry to the Windows system registry. Registry entries associated with objects can only be unregistered using code inside the associated object. That is, if the object no longer exists, it cannot be used for unregistering. Thus the registry can become cluttered with "orphaned" registrations.

  • Unregistering is important in several cases:
    • Before you remove a COM object from your system, you should unregister it.
    • If you register a COM object during application development but you subsequently decide not to save the application, you should always unregister the COM object before you abandon the application.

Registering an ActiveX server

  • To register an in-process or out-of-process ActiveX server (DLL, OCX, or EXE), choose either:
    • Run > ActiveX Server > Register
    • Run > ActiveX Server > Register for Current User
  • To unregister an ActiveX server, choose:
    • Run > ActiveX Server > Unregister
    • Unregister unregisters the ActiveX server both for per-user and for all users.

See Register/Unregister ActiveX Server.

Using Run Command Options

You can also register or unregister the server by running it with command line options for registering or unregistering. You can set command-line options with the Debugger options page.

Note: When you register an "out-of-process" (EXE) server, "Success" is reported if the executable successfully launches with the appropriate command line. That is, even though the message says "Successfully registered ActiveX Server 'xxxx.exe'", the server has no way to communicate to the IDE any information about success or failure of the registration or unregistration.

Out-of-Process Server

  • To register an out-of-process (EXE) server, run the server with either:
    • The /regserver command-line option
    • The /RegServerPerUser command-line option
  • To unregister an out-of-process (EXE) server, run the server with either:
    • The /unregserver command-line option
    • The /UnregServerPerUser command-line option

In-Process Server

You can use either the tregsvr utility or the regsvr32 command provided by the operating system:

  • To register an in-process (DLL) server, specify either:
    • regsvr32.exe /n <dllname>.dll
    • regsvr32.exe /n /i:user <dllname>.dll
  • To unregister an in-process (DLL) server, specify either:
    • regsvr32.exe /u /n <dllname>.dll
    • regsvr32.exe /u /n /i:user <dllname>.dll

See Also