0
votes

I want to load the dll base address as shown in the code below.

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

When I run it, I get the following error message:

 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

I also tried Qlibrary but I'm not able to load on hmodule.

Same code works fine when I just run it with visual studio 2010.

1

1 Answers

0
votes

_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:

  1. Define _UNICODE. This is application wide, so it may have other consequences for strings in your application.
  2. Instead of LoadLibraryW(), call LoadLibrary(), which will end up calling LoadLibraryA() behind the scenes if _UNICODE is not defined.
  3. 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.