• 8445阅读
  • 6回复

如何在qt下开发usb通讯程序需要加载usb芯片的dll文件 [复制链接]

上一主题 下一主题
离线unforgiver
 

只看楼主 倒序阅读 楼主  发表于: 2007-08-13
— 本帖被 XChinux 执行加亮操作(2007-08-13) —
环境:vc2003 +xp+qt4.2.1
由于需要qt下usb开发 芯片公司提供了 dll文件以及 .lib  .h文件 说明文件 都在附件中
问题1:    QLibrary lib("mpusbapi");
   
    if(lib.isLibrary("mpusbapi"))
    {
        ui.textEdit->append("mpusbapi is load");
    }
    else
    {
        ui.textEdit->append("mpusbapi not load");
    }
使用上面代码时候提示 mpusbapi not load
问题2:按照说明文件 在引入#include "mpusbapi.h" 后
提示: DWORD (*MPUSBGetDLLVersion)(void); 类似于这样的 DWORD类型无法编译

在vc下面 可以编译及使用在qt下面怎么加载以及使用dll 阿

救急阿谢谢各位了
[ 此贴被XChinux在2007-08-13 19:17重新编辑 ]
描述:所使用的dll文件以及说明
附件: Mpusbapi.rar (176 K) 下载次数:87
离线unforgiver

只看该作者 1楼 发表于: 2007-08-13
问题1已经解决 原来是 需要QLibrary lib("mpusbapi.dll"); 
第二个问题 怎么解决阿 谢谢各位了
离线XChinux

只看该作者 2楼 发表于: 2007-08-13
自己typedef一个DWORD,或者将windows.h头文件加进去 。
二笔 openSUSE Vim N9 BB10 XChinux@163.com 网易博客 腾讯微博
承接C++/Qt、Qt UI界面、PHP及预算报销系统开发业务
离线unforgiver

只看该作者 3楼 发表于: 2007-08-13
现在已经可以编译了There are two ways to link the DLL to your project:

a) Load-time Linking

  Simply add the mpusbapi.lib file to your project.
  The mpusbapi.lib file provided is specific to the Borland C++
  compiler. The mpusbapi.dll is compiler independent. If a different
  compiler is used, however, the DLL must be re-compiled to generate
  a new mpusbapi.lib specific to that compiler.

  C++ source code for MPUSBAPI is provided.
 
  The _mpusbapi.h file must be included in every file that uses
  the MPUSBAPI functions.

  The mpusbapi.dll file must be in the same directory as the
  executable file.

b) Run-time Linking

  Run-time Linking does not require the .lib file. It only requires
  the .dll file. Linking the functions is, however, a little more
  complicated. An example is provided showing how to use Win32
  API functions to load a DLL.

  The mpusbapi.h file (note, no "_") must be included in every file
  that uses the MPUSBAPI functions.

  The mpusbapi.dll is not required to be in the same directory as
  the executable file.
按照这两段说明 应该是使用第二种方法才对 可是 加载 mpusbapi.h 后 出现错误
离线unforgiver

只看该作者 4楼 发表于: 2007-08-13
错误提示
离线unforgiver

只看该作者 5楼 发表于: 2007-08-13
加载 _mpusbapi.h  在加载项目属性中加入mpusbapi.dll  后就穿了1 处的错误 。。。
离线unforgiver

只看该作者 6楼 发表于: 2007-08-13
1标注  处  加载 windows.h 和 qt_windows.h 错误相同
快速回复
限100 字节
 
上一个 下一个