Monday, May 7, 2012

Installing and Registering COM Servers and Type Libraries

Installing and Registering COM Servers and Type Libraries

Windows uses various kinds of COM servers and type libraries. InstallMate has built-in support for all of them as far as installation and registration is concerned (this includes unregistration and safe removal). In particular, it knows about:
  • In-process COM servers, essentially dynamic link libraries (DLLs) with .dll or .ocx file name extensions and special COM-defined entry points. (The actual file name extension is immaterial; InstallMate analyzes each installation file to determine its type and further characteristics.)
  • Out-of-process COM servers, which are stand-alone executable programs that adhere to certain COM conventions.
  • Type libraries, whether embedded in DLL or EXE files, or as stand-alone TLB files. (Again, InstallMate does not rely upon the file name extension, but inspects each installation file to see if it contains a type library.)
There are two ways of dealing with these types of files:
  • Use the file's built-in self-registration, or
  • Add explicit registration options for each file.
Using the built-in self-registration is the easiest from a development and maintenance point of view; it allows the file to control its own registration entries in the Windows registry. However, it does not allow the same amount of rollback protection as the explicit registration method.
Explicit registration requires you to specify, for each COM server or type library, exactly what needs to be registered for the file. This is more error prone, but it allows a degree of flexibility and control that is not available with self-registration.
Unless there is a good reason otherwise, we recommend that you use self-registration for the files.

Using the file's built-in self-registration

Here is how InstallMate deals with files that have built-in self-registration.
In-process COM servers
In-process COM servers have DllRegisterServer and DllUnregisterServer entry points that perform registration and unregistration upon request. InstallMate's Setup program calls these entry points as appropriate during installation and uninstallation of the server.
Out-of-process COM servers
Out-of-process COM servers adhere to the COM convention of using /RegServer and /UnregServer command line options to perform their registration and unregistration actions. When started with one of these options, the server is supposed to run invisibly and to terminate immediately after completing the (un-)registration. InstallMate's Setup program uses these command line options as appropriate during installation and uninstallation of the server. However, there are no hard and fast rules to recognize an out-of-process COM server, so you must judge for yourself whether or not registration is required.
Type libraries
Type libraries are sometimes contained in DLL files (often as part of an in-process COM server), sometimes in EXE files (presumably as part of an out-of-process COM server), and sometimes in a special type library file, usually with a .tlb file name extension. InstallMate's treatment of a type library depends on the situation, as follows:
  • If the type library is contained in a DLL file and that DLL file is an in-process COM server (i.e., has a DllRegisterServer entry point), InstallMate assumes that the server will register the type library as part of its overall registration process (as it should).
  • If the type library is contained in a DLL file and that DLL file is not an in-process COM server, InstallMate will register it with the Windows function RegisterTypeLib.
  • If the type library is contained in an EXE file, InstallMate assumes that the file is an out-of-process COM server and will suggest that it be registered as such. However, there are no hard and fast rules to recognize an out-of-process COM server, so you must judge for yourself whether or not registration is required.
  • If the type library is contained in a stand-alone TLB file, InstallMate will register it with the Windows function RegisterTypeLib.
Once again, the actual file name extensions are immaterial; InstallMate analyzes each installation file to determine its type and other characteristics.
COM servers and type libraries are typically installed as shared files in the Windows System folder. Within InstallMate, this folder is represented by the Windows\System (32-bit) folder. Unless you know what you are doing and have a very good reason to do otherwise, we recommend that you follow this convention.




Register/Unregister out-of-process COM server
CreatedApr 08, 2002
Last updateApr 08, 2002
Method #1Using command line parameters.
Register ' /regserver'
Unregister ' /unregserver'
Method #2Using Borland tregsvr.exe utility.
Registertregsvr.exe
Unregistertregsvr.exe -u
Note If you own Borland Delphi you can find source at: \Demos\ActiveX\TRegSvr\
Method #3Using Win32 API
RegisterLaunch exe COM server using CreateProcess API call with ' /regserver' parameter
UnregisterLaunch exe COM server using CreateProcess API call with ' /unregserver' parameter
 

No comments:

Post a Comment

Health Benefits of Cashews

  Benefits of Cashews. Healthy food is an integral part of healthy body. Regular exercises such as Yoga and healthy diet is important to...