How to import a tlb and a namespace in c++ at runtime when some condition meets?

爱⌒轻易说出口 提交于 2020-01-02 18:34:33

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/1108537/how-to-import-a-tlb-and-a-namespace-in-c-at-runtime-when-some-condition-meets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!