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. COM object + dll
Forum Updated to NodeBB v4.3 + New Features

COM object + dll

Scheduled Pinned Locked Moved Solved General and Desktop
comdllc++
6 Posts 3 Posters 3.8k Views
  • 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.
  • P Offline
    P Offline
    Psy_Duck
    wrote on 13 Jan 2016, 08:40 last edited by
    #1

    Hello all. I need work with cardreader in QT using driver and dll. I just show you code at VS:

    #include "stdafx.h"
    #include <windows.h>
    #include "Objbase.h"
    #import "MifareDrv.dll" rename_namespace("mifare") 
    CLSID clsid;
    IDispatch *pWApp;
    mifare::IMifareDrv *pMiDrv;
    int _tmain(int argc, _TCHAR* argv[])
    {
    	HRESULT hr = CLSIDFromProgID(L"Addin.MifareDrv", &clsid);
    	if (SUCCEEDED(hr))
    	{
    		LPOLESTR tmpbuf;
    		StringFromCLSID(clsid, &tmpbuf);
    		CoInitializeEx(NULL, COINIT_MULTITHREADED);
    		hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, IID_IDispatch, (void **)&pWApp);
    		hr = pWApp->QueryInterface(__uuidof(mifare::IMifareDrv), (void **)&pMiDrv);
    		pMiDrv->FindDevice();
    		pMiDrv->Connect();
    		pMiDrv->BeepTone = 1;
    		pMiDrv->PcdBeep();
    
    	}
    		return 0;
    }
    

    I rewriting this code for Qt but trying to stick to the original.
    In pro. i write

    LIBS += -lole32 -loleaut32 -luuid
    

    in .cpp:

    #include <QCoreApplication>
    #include "windows.h"
    #include "objbase.h"
    #include <QLibrary>
    CLSID clsid;
    IDispatch *pWApp;
    HRESULT hr = CLSIDFromProgID(L"Addin.MifareDrv", &clsid);
    int main(int argc, char *argv[])
    {
        QCoreApplication a(argc, argv);
        QLibrary myLib ("MifareDrv.dll");
        myLib::IMifareDrv *pMiDrv;
        LPOLESTR tmpbuf;
        StringFromCLSID(clsid, &tmpbuf);
        CoInitializeEx(NULL, COINIT_MULTITHREADED);
        hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, IID_IDispatch, (void **)&pWApp);
        hr = pWApp->QueryInterface(QUuid(__uuidof(myLib::IMifareDrv)), (void **)&pMiDrv);
    
        return a.exec();
    }
    

    And yep, i have trouble with "myLib::IMifareDrv". Can anybody help me to write and how to replace me "#import"? Or how this code should look with QAxBase.

    1 Reply Last reply
    0
    • H Online
      H Online
      hskoglund
      wrote on 13 Jan 2016, 13:19 last edited by
      #2

      Hi, if you have the .tlb file for the MiFare driver, instead of #importing, you could try using Qt's dumpcpp utility
      For a good example on how to use it, see here

      P 1 Reply Last reply 13 Jan 2016, 15:41
      0
      • H hskoglund
        13 Jan 2016, 13:19

        Hi, if you have the .tlb file for the MiFare driver, instead of #importing, you could try using Qt's dumpcpp utility
        For a good example on how to use it, see here

        P Offline
        P Offline
        Psy_Duck
        wrote on 13 Jan 2016, 15:41 last edited by
        #3

        @hskoglund I'm trying it. I create cpp and h, but when I wrote the code I got the next problem: "return type 'struct MifareLib::TSAMVersion' is incomplete
        inline TSAMVersion MifareDrv::SAMVersion() const"
        I find TSAMVersion, it struct has prototype, but hasn't realization.
        Do you have any idea?

        1 Reply Last reply
        0
        • H Online
          H Online
          hskoglund
          wrote on 13 Jan 2016, 16:24 last edited by
          #4

          Hi, maybe that SAMVersion() function is not important, you could try commenting it out...

          P 1 Reply Last reply 14 Jan 2016, 19:56
          1
          • H hskoglund
            13 Jan 2016, 16:24

            Hi, maybe that SAMVersion() function is not important, you could try commenting it out...

            P Offline
            P Offline
            Psy_Duck
            wrote on 14 Jan 2016, 19:56 last edited by
            #5

            @hskoglund i decided to throw off their problem and the code here, can someone else help
            #include <QApplication>
            #include <QAxWidget>
            QAxWidget *drvFR;
            #define CLSID_DrvFR "{450E3DC0-5370-4007-BD5F-90827EC2C2D6}" // it's GUID for driver object (my Addin.MifareDrv). GUID can be found in registry
            int main(int argc, char *argv[])
            {
            QApplication a(argc, argv);
            drvFR = new QAxWidget();
            drvFR->setControl(CLSID_DrvFR);
            drvFR->dynamicCall("FindDevice()");
            drvFR->dynamicCall("Connect()");
            drvFR->setProperty("BeepTone", 1);
            drvFR->dynamicCall("PcdBeep()");
            ....
            and of course in .pro write QT += axcontainer.

            Thank you for trying help.

            1 Reply Last reply
            0
            • O Offline
              O Offline
              opengpu
              wrote on 26 Apr 2019, 09:32 last edited by
              #6

              the problem is solved or not?

              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