Loading a COM DLL (no headers) in QT with C++?
-
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!
-
I'm using the QT Creator for this
-
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] -
#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
-
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! -