Adding Type Libraries as Resources to .DLL and .EXE Files

Last reviewed: March 15, 1996
Article ID: Q122285
The information in this article applies to:
  • Microsoft OLE Libraries for Windows 95, Windows NT 3.51, and Win32s, version 2.02

A type library can be added 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 reference words: 2.00 Automation
KBCategory: kbole kbprg
KBSubcategory: LeTwoAto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: March 15, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.