[SOLVED] issue with loading dll base address
hi I want to load dll base address as shown in the code below
g_hDll = LoadLibraryW(_T("4FM.dll"));
when i run it says
" C:\Qt\UPI_ProIII_062414085021\fpga_lib\sipif.cpp:106: error: C2664: 'HMODULE LoadLibraryW(LPCWSTR)' : cannot convert argument 1 from 'const char ' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast"
i also tried Qlibrary but i am not able to load on hmodule
this works fine when i just run c++ using Visual studio 2010
LPCWSTR is a const char*
std::string str = std::string(path.toAscii().data());
const char * var = str.c_str();
not working :(
C:\Qt\UPI_ProIII_062414085021\fpga_lib\sipif.cpp:108: error: C2039: 'toAscii' : is not a member of 'QString'
[quote author="habbas33" date="1406193293"]not working :(
C:\Qt\UPI_ProIII_062414085021\fpga_lib\sipif.cpp:108: error: C2039: 'toAscii' : is not a member of 'QString'[/quote]
use toLatin1() instead of toAscii();
_T() denotes either multi-byte or wide string on Win32 depending on whether or not _UNICODE is #defined. In your case, it must not be. So you have several options here:
Define _UNICODE. This is application wide, so it may have other consequences for strings in your application.
Instead of LoadLibraryW(), call LoadLibrary(), which will end up calling LoadLibraryA() behind the scenes if _UNICODE is not defined.
Instead of using _T("my string"), use L"my string" to force wide characters.
All of this is explained in some detail over at MSDN.