预备知识:
1、如果在没有导入库文件(.lib),而只有头文件(.h)与动态链接库(.dll)时,我们才需要显示调用,如果这三个文件都全的话,我们就可以使用简单方便的隐式调用。
2、通常Windows下程序显示调用dll的步骤分为三步(三个函数):LoadLibrary()、GetProcAdress()、FreeLibrary()
其中,LoadLibrary() 函数用来载入指定的dll文件,加载到调用程序的内存中(DLL没有自己的内存!)
GetProcAddress() 函数检索指定的动态链接库(DLL)中的输出库函数地址,以备调用
FreeLibrary() 释放dll所占空间
1、显示调用
Qt提供了一个 QLibrary 类供显示调用。下面给出一个完整的例子:
1 #include <QApplication>
2 #include <QLibrary>
3 #include <QDebug>
4 #include <QMessageBox>
5 #include "dll.h" //引入头文件
6 typedef int (*Fun)(int,int); /
2 #include <QLibrary>
3 #include <QDebug>
4 #include <QMessageBox>
5 #include "dll.h" //引入头文件
6 typedef int (*Fun)(int,int); /