woshigaowei5 |
2019-08-13 18:14 |
QT如何调用外部DLL中的类中的函数?
我现在只有一个外部dll文件**Protocol.dll**,想用QT调用里面的函数,没有.h和.lib。 在网上找了许多方法都不行。 厂家只给了一个**C#**的例程,程序如下: Protocol.Ax1485 ax1485 = new Protocol.Ax1485();ax1485.OpenPort()其中**Ax1485**是一个类,**OpenPort()**是该类中的一个函数,我现在想用QT调用这个函数。我现在是这么做的: typedef int (*Fun)();QLibrary testLib("Protocol.dll"); //已经把dll放在debug中if (testLib.load()){Fun getObj = (Fun)testLib.resolve("OpenPort");if (getObj){qDebug()<<"getObj";}else{QMessageBox::about(NULL,"result","resolve unSuccessfully");}}load()成功,但是**resolve()**函数总是不成功,不知道为什么?有没有懂的,急求!!!
|
|