Microsoft KB Archive/122285

= How To Add Type Libraries as Resources to .dll and .exe Files =

Article ID: 122285

Article Last Modified on 3/3/2005

-

APPLIES TO


 * Microsoft OLE 2.03

-



This article was previously published under Q122285



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

Keywords: kbhowto KB122285

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.