QT with USB



  • HI ,guys
    I get job last week;the Manager want me to transplant a vc6 project into Qt;
    I got all the codes;
    but here is a question I come across:
    in vc6 we can send a control message to a usb device by function "DeviceIoControl" in MSDN:
    DeviceIoControl
    The DeviceIoControl function sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation.

    BOOL DeviceIoControl(
    HANDLE hDevice, // handle to device
    DWORD dwIoControlCode, // operation
    LPVOID lpInBuffer, // input data buffer
    DWORD nInBufferSize, // size of input data buffer
    LPVOID lpOutBuffer, // output data buffer
    DWORD nOutBufferSize, // size of output data buffer
    LPDWORD lpBytesReturned, // byte count
    LPOVERLAPPED lpOverlapped // overlapped information
    );
    I found this funcjtion in the vc project .but for a Qt project how to write/read datas into a USB device?



  • This DeviceIoControl() function is a part of Win32 API, and does not related to Qt at all. So, you can use this function as well as in VS. Please read the MSDN to find out a Win-API headers which need to include to your project.



  • @kuzulis
    another question I got DLL build by vc6 ,here is the function inside:
    #ifndef DLL_API
    #define DLL_API extern "C" __declspec(dllimport)
    #endif

    #define WIN_API __stdcall

    ....................
    DLL_API void WINAPI HTDrawTopPentagon(HDC hDC,int nCenterX,int nCenterY,COLORREF clr);
    ...................
    in QT I wang to use these funtions.
    will it work if I program like this:
    "
    QLibrary myLib("dll_name");

    typedef int (*MyPrototype)(QPixmap* ,int,int,QColor);
    MyPrototype myFunction = (MyPrototype) myLib.resolve("HTDrawTopPentagon");
    

    myFunction test;
    will test work?
    or should i typedef int (*MyPrototype)(HDC ,int,int,COLORREF);in QT?



  • or should i typedef int (*MyPrototype)(HDC ,int,int,COLORREF);in QT?

    yes



  • Hi,
    Because Qt is cross platform using a WinAPI is bad form. Shouldn't you switch to libusb making it cross platform?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.