HOWTO: Add Type Libraries as Resources to .dll and .exe Files

ID: Q122285

The information in this article applies to:

You can add a type library as a resource to an .exe or .dll file by using the following statement in the .rc file:

   1 typelib Test.tlb

Test.tlb is the type library to be added as a resource.

If a type library is added as a resource, a separate .tlb file need not be shipped with the application. LoadTypeLib() and LoadRegTypeLib() can be used to load the type library from the .exe or .dll file in which it exists as a resource.

NOTE: OLE version 2.02 or higher is needed to read a type library from an .exe file.

An .exe or .dll file can contain multiple typelib resources. For example:

1 typelib Test1.tlb 2 typelib Test2.tlb

Test1.tlb and Test2.tlb are type libraries to be added as resources.

By default, LoadTypeLib extracts the type library from the first resource of type typelib. To load a different type library resource, append an integer index to the szFileName parameter of LoadTypeLib. For example:

LoadTypeLib(OLESTR("c:\\test.exe\\2"), &ptlib);

This statement loads the type library resource 2 from Test.exe.

Additional query words: 2.00 Automation kbOLE kbDSupport

Version           : Windows: 2.02
Platform          : WINDOWS
Issue type        : kbhowto

Last Reviewed: May 18, 1998