1.
将ControlCAN.dll和ControlCAN.h拷贝到工程源文件所在的文件夹下
2.
在 工程名.pro 文件内加入,如图所示
LIBS += D:/Qt/CAN_ComPro/debug/ControlCAN.dll
3.
库函数的显示调用(以 VCI_OpenDevice为例):
#include <QLibrary>
#include <QDebug>
#include "ControlCAN.h"
typedef DWORD(__stdcall VCI_OpenDevice)(DWORD,DWORD,DWORD);
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
//导入库
QLibrary lib("ControlCAN.dll");
if(true==lib.load())
qDebug()<<"dll load ok";
//从库中解析函数
pOpenDevice = (VCI_OpenDevice *)lib.resolve("VCI_OpenDevice");
//调用函数
pOpenDevice(4, 0, 0);
return a.exec();
}
Over