April 16, 2011

DmT021 DmT021
Lab Rat
16 posts

Load the object from dll

 

Hello all
There is a dll which I need to use.
I have an interface looks like this:

  1. [ object, uuid("00000000-0000-0000-0000-000000000000") ]
  2. __interface Interface
  3. {
  4. public:
  5.     virtual bool Init(void) = 0;
  6.     virtual bool Destroy(void) = 0;
  7.     virtual bool Test(void) = 0;
  8. };

There is a function in the dll, which gives a pointer to object of class with implements of that interface.

I can load the dll using QLibrary, and I can resolve this function, and call it. But how to declare the interface in the right way using QT Qt? And how to call the methods of given object?

2 replies

April 22, 2011

DmT021 DmT021
Lab Rat
16 posts

solve:

  1. static const GUID IID_object = { 0x00000000, 0x0000, 0x0000, { 0x00, 0x00, 0x0, 0x00, 0x00, 0x00, 0x0, 0x00 } };
  2. class Interface : IUnknown
  3. {
  4. public:
  5.     virtual bool Init(void) = 0;
  6.     virtual bool Destroy(void) = 0;
  7.     virtual bool Test(void) = 0;
  8. };

PS: guid also could be resolved via QUuid

April 22, 2011

Gerolf Gerolf
Area 51 Engineer
3213 posts

Looks like you are using COM, right?
Why don’t you use COM methods then? like CoCreateInstance etc?

 Signature 

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

 
  ‹‹ Accessing files from a file server with a cross-platform app      (Beginner) How do I summon this dialog? ››

You must log in to post a reply. Not a member yet? Register here!