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] Using LoadLibrary to load a DLL with QString
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Using LoadLibrary to load a DLL with QString

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 5.0k Views 1 Watching
  • 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.
  • F Offline
    F Offline
    frankiefrank
    wrote on last edited by
    #1

    I'm writing a wrapper for a DLL, and want to use the windows API to load it. I understand I'm supposeDd to do it like this:
    @LoadLibrary(_T("MyDllFilenameHere.dll"));@

    But I want to pass the name of the DLL to the class as a QString argument, then to load the specified file by its name.

    The _T macro is translated to __T and then to the macro
    @#define __T(x) L ## x@

    Which means that a simple string literal is expected. How can I modify the code to work with my QString parameter?

    "Roads? Where we're going, we don't need roads."

    1 Reply Last reply
    0
    • E Offline
      E Offline
      elmigranto
      wrote on last edited by
      #2

      bq. Which means that a simple string literal is expected

      No, it means wide-string literal.
      Also, why not unicode-aware LoadLibraryW, it's 2012?!

      Since unicode is on, use "QString::toWCharArray":http://qt-project.org/doc/qt-4.8/qstring.html#toWCharArray.

      @LoadLibraryW( filename.toWCharArray() )@

      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