From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.



从CVI链接到DLL中定义的函数



主要软件: LabWindows/CVI Development Systems>>LabWindows/CVI Full Development System
主要软件版本: 8.0.1
主要软件修正版本: N/A
次要软件: N/A

问题: 如何从LabWindows/CVI链接到动态链接库(DLL)中定义的函数?

解答: 为了使LabWindows/CVI明白如何从源程序代码调用外部DLL中定义的函数,您需要提供一个能让LabWindows/CVI明白从何处查找该函数的机制。一种方法是使用DLL的 import library。

DLL和与之对应的import library一起,使得LabWindows/CVI能够将其调用的函数链接到函数的定义。DLL对应的import library的文件名与该DLL一样,但它的后缀为.lib,而不是.dll。

为了能够在LabWindows/CVI中顺利调用DLL中的函数,您需要将相应的import library添加到LabWindows/CVI项目中。即,进行如下操作:打开您的LabWindows/CVI项目,并选择Edit » Add Files to Project » Library (*.lib)。然后找到您的import library并选择将其添加到项目中。之后,当LabWindows/CVI在链接过程中试图解析您所调用的函数时便会转入到import library中,并且,import library将会告诉LabWindows/CVI所调用的函数在哪里被定义。

如果所发布的DLL没有提供相应的import library,但是,如果有相应的头文件,那么您可以用LabWindows/CVI生成一个import library。请参考知识库中关于创建import library的文章:在LabWindows/CVI中为DLL创建一个Import Libraries

如果您在调用DLL时不希望使用import library,请参考知识库的文章:如何在LabWindows/CVI调用DLl但又不使用Import Library ?

相关链接: KnowledgeBase 1ZQELEY5: Creating Import Libraries for a DLL in LabWindows/CVI
Developer Zone Tutorial: Using Dynamic Link Libraries with LabWindows/CVI
KnowledgeBase 2EIBT1Y1: How Can I Access DLL Functions in a LabWindows/CVI Program Without Including the Import Library in the Project?

附件:





报告日期: 07/27/2000
最近更新: 11/04/2007
文档编号: 1ZQDQPY5