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. Loading a COM DLL (no headers) in QT with C++?
Forum Updated to NodeBB v4.3 + New Features

Loading a COM DLL (no headers) in QT with C++?

Scheduled Pinned Locked Moved General and Desktop
10 Posts 5 Posters 5.1k 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.
  • G Offline
    G Offline
    godplusplus
    wrote on last edited by
    #1

    Hello everyone,

    I just started using QT. Right now I need to transfer some code I have on a Visual C++ project to QT.

    The only thing the project does at the moment is open photoshop and set the visible flag to false (it will be used for automation, so a lot of things will be added later).

    What I do is, I import 2 photoshop dlls (NOTE: I don't have .h or .lib for them, just the .dll files)
    The method I'm using to import these dlls is through import libid, since all the other methods I tried didn't work. They are COM objects, btw.

    This is my VC++ code:
    [code]
    //library ID of Photoshop.dll
    #import "libid:E891EE9A-D0AE-4cb4-8871-F92C0109F18E"
    //library ID of PhotoshopTypeLibrary.dll
    #import "libid:4B0AB3E1-80F1-11CF-86B4-444553540000"

    int main()
    {
    Photoshop::_ApplicationPtr app( __uuidof(Photoshop::Application));
    app->Visible = false;

    return 0;
    }
    [/code]

    Now, QT gives me some warnings and errors on the import lines:

    [code]
    warning: #import is a deprecated GCC extension
    error: libid:E891EE9A-D0AE-4cb4-8871-F92C0109F18E: No such file or directory
    [/code]

    And then, after that, it says (obviously) that "Photoshop" is not declared.

    Now, I searched and the closest solution I found was to include the .tlh files that were created on my VC++ project, but when I did that, I got more than 1 thousand errors and warnings, so that obviously didn't work.

    Can someone please tell me what to do here? I'm seriously stuck!

    1 Reply Last reply
    0
    • T Offline
      T Offline
      t3chNo
      wrote on last edited by
      #2

      Which compiler are you using?

      1 Reply Last reply
      0
      • G Offline
        G Offline
        godplusplus
        wrote on last edited by
        #3

        I'm using the QT Creator for this

        1 Reply Last reply
        0
        • T Offline
          T Offline
          t3chNo
          wrote on last edited by
          #4

          I suppose you are using mingw. Afaik, mingw has no support importing dlls like this. You have to import dlls in project(.pro) file. If you have to import dlls like this, you have to use msvc compiler.

          1 Reply Last reply
          0
          • G Offline
            G Offline
            godplusplus
            wrote on last edited by
            #5

            You're right, I'm using MinGW.
            I'll check with msvc to see if it works.
            With MinGW, however, how would I import the dlls in the project file? I saw some threads about people adding the location of the dll there, however, I don't really have the locations of these dlls (one of the reasons I had to use the libids on the original project)

            EDIT: I tried with the msvc compiler. It does compile now, but it crashes saying:
            [quote]signal received
            The inferior stopped because it received a signal from the Operating System.
            Signal name: ?
            Signal meaning: Unknown signal
            [/quote]

            1 Reply Last reply
            0
            • T Offline
              T Offline
              t3chNo
              wrote on last edited by
              #6

              For reference documentation adding dlls in your project, you can look at LIBS variable in qmake Reference.

              1 Reply Last reply
              0
              • G Offline
                G Offline
                giesbert
                wrote on last edited by
                #7

                #import is a MS specific thing to use native com support.
                There are ways for that in Qt, using ActiveQt (see the docs for that).
                I know it is possible, but I never tried it on my own.

                The other way would be the already proposed one:

                use the MS toolchain together with QtCreator

                Nokia Certified Qt Specialist.
                Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  godplusplus
                  wrote on last edited by
                  #8

                  I managed to get it working.
                  I used the dumpcpp utility from the qt sdk.
                  In the command line (from QT sdk), I put:
                  [code]dumpcpp {library_guid_goes_here}[/code]

                  I got the library guid from ole com viewer.
                  Anyway, it created a .h and .cpp files which I then included in the project, then had to do a couple of adjustments and that's it, it worked!

                  1 Reply Last reply
                  0
                  • KyefK Offline
                    KyefK Offline
                    Kyef
                    wrote on last edited by
                    #9

                    This is a very old topic but I have ran into the same need. How did you resolve this? I have .DLL file to import into my QT project. #import QBXMLRP.dll does not seem to work. says: main.cpp:14:2: #import of type library is an unsupported Microsoft feature.

                    Kyef Elliot
                    If Can Imagine It...I Can Do It!!

                    1 Reply Last reply
                    0
                    • hskoglundH Offline
                      hskoglundH Offline
                      hskoglund
                      wrote on last edited by
                      #10

                      Hi, perhaps you're using the MinGW compiler? I think #import only works with MSVC compilers.

                      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