Home > How-To > Register/Unregister type library

Created Sep 12, 2001
Last update Jan 08, 2002
 
Method #1 Using Borland tregsvr.exe utility. 
Register tregsvr.exe <type library file>
Unregister tregsvr.exe -u <type library file>
Note If you own Borland Delphi you can find source at: <Delphi>\Demos\ActiveX\TRegSvr\
 
Method #2 Using Microsoft regtlib.exe utility.
Register regtlib.exe <type library file>
Unregister Unfortunatly it has no unregister functionality ;-(.
Note

Next Microsoft products are shipped with it:

BackOffice 4.5
Commerce Server 2000
Internet Explorer 5.0 - 5.5
Office 2000 Developer
Office 2000
Small Business Server 2000
Visual Studio 6.0
Visual Studio 6.0 SP2 - SP5

 
Method #3 Using Win32 API
Register 1. Call LoadTypeLib function to get ITypeLib interface pointer
2. Call RegisterTypeLib to register type library using ITypeLib
Unregister 1. Call LoadTypeLib function to get ITypeLib interface pointer
2. Call GetLibAttr method of ITypeLib interface to get pointer to Type Library attributes
3. Call UnRegisterTypeLib to unregister type library
 
Delphi code function RegisterTLB(const aFile: string): boolean;
var
  vWFileName: WideString;
  vITypeLib : ITypeLib;
begin
  Result := False;
  vWFileName := aFile;
  if Succeeded(LoadTypeLib(PWideChar(vWFileName), vITypeLib)) then
    Result := Succeeded(RegisterTypeLib(vITypeLib, PWideChar(vWFileName), nil));
end;
 
function UnRegisterTLB(const aFile: string): boolean;
var
  vWFileName: WideString;
  vITypeLib : ITypeLib;
  vLibAttr  : PTLibAttr;
begin
  Result := False;
  vWFileName := aFile;
  if Succeeded(LoadTypeLib(PWideChar(vWFileName), vITypeLib)) then
    if Succeeded(vITypeLib.GetLibAttr(vLibAttr)) then
    begin
      with vLibAttr^ do
        Result := Succeeded(UnRegisterTypeLib(Guid, wMajorVerNum, wMinorVerNum, LCID, SysKind));
      vITypeLib.ReleaseTLibAttr(vLibAttr);
    end;
end;
 
See also RegCOM
Hosted by www.Geocities.ws

1