Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] issue with loading dll base address

[SOLVED] issue with loading dll base address

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 2.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    habbas33
    wrote on last edited by
    #1

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

    HMODULE g_hDll;
    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 [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 am not able to load on hmodule

    1 Reply Last reply
    0
    • H Offline
      H Offline
      habbas33
      wrote on last edited by
      #2

      this works fine when i just run c++ using Visual studio 2010

      1 Reply Last reply
      0
      • IamSumitI Offline
        IamSumitI Offline
        IamSumit
        wrote on last edited by
        #3

        Hiii.
        Try this

        LPCWSTR is a const char*
        Try
        QString path="4FM.dll";
        std::string str = std::string(path.toAscii().data());
        const char * var = str.c_str();
        LoadLibraryW(var);

        Be Cute

        1 Reply Last reply
        0
        • H Offline
          H Offline
          habbas33
          wrote on last edited by
          #4

          not working :(

          C:\Qt\UPI_ProIII_062414085021\fpga_lib\sipif.cpp:108: error: C2039: 'toAscii' : is not a member of 'QString'

          1 Reply Last reply
          0
          • IamSumitI Offline
            IamSumitI Offline
            IamSumit
            wrote on last edited by
            #5

            [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();
            from Docs.
            http://qt-project.org/wiki/Transition_from_Qt_4.x_to_Qt5

            Be Cute

            1 Reply Last reply
            0
            • H Offline
              H Offline
              habbas33
              wrote on last edited by
              #6

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

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved