2014-07-24 113 views
0

我想加載dll的基地址,如下面的代碼所示。加載dll基址的QT問題HMODULE

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

回答

0

_T()表示無論多字節或取決於是否_UNICODE已經#defined寬字符串在Win32。在你的情況下,它不一定是。所以你有幾種選擇:

  1. 定義_UNICODE。這在應用程序範圍內,因此它可能會對應用程序中的字符串造成其他後果。
  2. 而不是LoadLibraryW()調用LoadLibrary(),如果未定義_UNICODE,它將在幕後調用LoadLibraryA()。
  3. 而不是使用_T(「我的字符串」),使用L「我的字符串」來強制寬字符。

所有這一切都是explained in some detail over at MSDN