Load and Register typelib

The Automation dynamic link library, Oleaut32.dll, provides several functions that you can call to load and register a type library.

// Loads and registers a type library.
HRESULT LoadTypeLib(
   LPCOLESTR szFile,   // The name of the type library file
   ITypeLib  **pptlib  // The loaded type library

// Loads a type library and (optionally) registers it in the system registry. 
HRESULT LoadTypeLibEx(
   LPCOLESTR szFile,  // The name of the type library file
   REGKIND   regkind,  //Identifies the kind of registration flags: DEFAULT, REGISTER and NONE
   ITypeLib  **pptlib  // The loaded type library

// Adds information about a type library to the system registry.
HRESULT RegisterTypeLib(
           ITypeLib  *ptlib, // The type library.
  _In_     LPCOLESTR szFullPath, // The fully qualified path specification for the type library.
  _In_opt_ LPCOLESTR szHelpDir  // The directory in which the Help file can be found

HRESULT UnRegisterTypeLib(
   WORD    wVerMajor,
   WORD    wVerMinor,
   LCID    lcid,
   SYSKIND syskind

Register typelib code

Example: Calling LoadTypeLibEx, as shown in this example, both loads the library and creates the registry entries.

ITypeLib *pTypeLib;
hr = LoadTypeLibEx("example.tlb", REGKIND_REGISTER, &pTypeLib);

About our authors: Team EQA

You have viewed 1 page out of 67. Your COM/DCOM learning is 0.00% complete. Login to check your learning progress.