本文介绍了如何在运行时在某些条件满足时在c ++中导入tlb和命名空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常我们在程序开始时导入一个tlb文件,如

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

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

但是我需要导入tlb文件条件在程序中间满足

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

我如何做到这一点。加载dll有 LoadLibrary()但是加载tlb可以使用 LoadLibrary()

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

由于tlb是使用.dll生成的

Since tlb is generated by using .dll?

推荐答案

在运行时使用。

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

ptlib

ptlib 是支持界面的对象。它有一些方法,你可以调用枚举和类型库中的类型迭代。通常,您可以与其他界面(如)结合使用。

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

这篇关于如何在运行时在某些条件满足时在c ++中导入tlb和命名空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 16:07