【问题标题】:QT issue with loading dll base address HMODULE加载 dll 基地址 HMODULE 的 QT 问题
【发布时间】:2014-07-24 08:10:53
【问题描述】:

我想加载如下代码所示的dll基地址。

HMODULE g_hDll; 
g_hDll = LoadLibraryW(_T(“4FM.dll”));`

当我运行它时,我收到以下错误消息:

 C:\Qt\UPI_ProIII_062414085021\fpga_lib\sipif.cpp:106: error: C2664: ‘HMODULE LoadLibraryW(LPCWSTR)’ : cannot convert argument 1 from ‘const char [8]’ to ‘LPCWSTR’
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

我也尝试了Qlibrary,但我无法在hmodule 上加载。

当我使用 Visual Studio 2010 运行相同的代码时,它运行良好。

【问题讨论】:

    标签: c++ qt dll


    【解决方案1】:

    _T() 表示 Win32 上的多字节或宽字符串,具体取决于 _UNICODE 是否为#defined。在你的情况下,它一定不是。所以你有几个选择:

    1. 定义_UNICODE。这是应用程序范围内的,因此它可能会对应用程序中的字符串产生其他影响。
    2. 调用 LoadLibrary() 而不是 LoadLibraryW(),如果未定义 _UNICODE,最终将在后台调用 LoadLibraryA()。
    3. 不要使用 _T("my string"),而是使用 L"my string" 来强制使用宽字符。

    所有这些都是explained in some detail over at MSDN

    【讨论】:

      猜你喜欢
      • 2011-05-26
      • 2016-02-08
      • 1970-01-01
      • 2011-09-03
      • 1970-01-01
      • 2021-12-08
      相关资源
      最近更新 更多