Answer the question
In order to leave comments, you need to log in
C++, Qt, how to use driver functions (dll) correctly?
Welcome all. I apologize in advance, but the question is in the style of "please show me how to make shobeverything was cool."
There is a driver for working with the device via COM-port (transmission goes through FTDI) (the driver is operational and the tests are plowed) with the name "MifareDrv.dll" and the object name AddIn.MifareDrv . By the way, there is even an example of connecting a Delphi driver via OleControl:
uses MifareLib_TLB;
var
Driver: TMifareDrv;
begin
Driver := TMifareDrv.Create(nil);
Driver.Beep;
end;
typedef void (*Connect) ();
Connect con = (Connect)mylib.resolve ("Beep");
con ();
Answer the question
In order to leave comments, you need to log in
In the end, I decided everything
. In my case, here is the correct code in Visual C ++
// ConsoleApplication5.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <windows.h>
#include "Objbase.h"
#import "MifareDrv.tlb" rename_namespace("mifare")
CLSID clsid;
mifare::IMifareDrv ;
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); // инициализация COM для ридеров
hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, IID_IDispatch, (void **)&pWApp);
hr = pWApp->QueryInterface(__uuidof(mifare::IMifareDrv), (void **)&pMiDrv);
pMiDrv->PortNumber = 4;
pMiDrv->Connect();
pMiDrv->BeepTone = 1;
pMiDrv->PcdBeep();
}
return 0;
}
#include <QApplication>
#include <QAxWidget>
QAxWidget *drvFR;
#define CLSID_DrvFR "{450E3DC0-5370-4007-BD5F-90827EC2C2D6}" // это GUID для объекта драйвера (у меня он звался Addin.MifareDrv). GUID вытащил из регистра
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()");
....
и дописать в .pro write QT += axcontainer.
Hiking with the driver, you need to work like with a COM object doc.qt.io/qt-4.8/activeqt-container.html
Since it's a DLL, it probably has exports. Accordingly, LoadLibrary + GetProcAddress will surely be able to do the same thing that you are trying to do through the code you provided. And in case of errors, GetLastError will show what is wrong. But in general, without the DLL itself, guessing on the coffee grounds.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question