views:

816

answers:

1

Hi

Generally we import a tlb file at the starting of the program like

#include < stdio.h >
#import " sql.tlb "

But i need to import a tlb file when certain condition meets in the middle of the program

how can i do this. to load dll there is LoadLibrary() but to load tlb can i use LoadLibrary().

Since tlb is generated by using .dll?

+6  A: 

You can load a type library at runtime using LoadTypeLib.

ITypeLib *ptlib;
LoadTypeLib("sql.tlb", &ptlib);

What you do then with ptlib is kind of up in the air as you don't really say what you are trying to do with it.

ptlib is an object supporting the ITypeLib interface. It has methods which you can call to enumerate and iterate the types in the type library. Normally you use it in combination with the other interfaces like ITypeInfo and so on.

I found a fuller tutorial style document here. Also, this link here has some more detail, also it shows the header file and link library you need to use.

Header                    oaidl.h, oaidl.idl
Library                   oleaut32.lib, uuid.lib
Windows Embedded CE       Windows CE 2.0 and later
Windows Mobile            Windows Mobile Version 5.0 and later
1800 INFORMATION
But loading the type library in the middle of progrm is my requirement
Cute
What do you mean by "in the middle of program"? At runtime? Or at compile time? Or in the middle of some file? Please explain more.
1800 INFORMATION
I added some more detail
1800 INFORMATION
Can i use this in c++ what header file i need to include to use this one.
Cute
@Cute - in the answer above, the part where it says LoadTypeLib, that's called a link. Try clicking it.
Daniel Earwicker
I added more detail on the header files and so on
1800 INFORMATION
in the same manner how can i load namespaces??
Cute
What namespace are you talking about? The type library has no concept of a namespace
1800 INFORMATION