Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Load the object from dll



  • Hello all
    There is a dll which I need to use.
    I have an interface looks like this:
    @[ object, uuid("00000000-0000-0000-0000-000000000000") ]
    __interface Interface
    {
    public:
    virtual bool Init(void) = 0;
    virtual bool Destroy(void) = 0;
    virtual bool Test(void) = 0;
    };
    @
    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?



  • solve:
    @static const GUID IID_object = { 0x00000000, 0x0000, 0x0000, { 0x00, 0x00, 0x0, 0x00, 0x00, 0x00, 0x0, 0x00 } };
    class Interface : IUnknown
    {
    public:
    virtual bool Init(void) = 0;
    virtual bool Destroy(void) = 0;
    virtual bool Test(void) = 0;
    };@

    PS: guid also could be resolved via QUuid



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


Log in to reply