Detect Operating system of SmartPhone connected to PC using QT

  • Hi,

    I have a QT application. In this application I can detect if a device is connected by ::winevent( WM_DEVICECHANGE).

    But I want to have information on the device which is connected/pluggedin to my PC like the OS running on that device( if it's a smartphone then if it is Abdroid/ Symbian/ Iphone etc?)

    Can somebody please help me?


  • There is no Qt API to do this, sorry.

  • How about to look into DEV_BROADCAST_OEM struct?
    You actually need usb device information, on that info you can determine which OS is on. When you can use this information to get more specific information about OS. For example you can do that with WINAPI for Windows Mobile maybe for Windows Phone too, I don't know. And for Android you can use fastboot to check OS information(if debug usb is activated), where was also SDK functions for Symbian OS determination. etc...

  • Hi Robert,

    Thanks so much for your quick reply.

    My application is written in using QT SDK 4.7.4 and runs on desktops.
    In this application I want to show user a message when they plugin their smartphones like ( You have plugged in a Symbian/Android/Iphone device).

    I guess you are talking about below structure:

    typedef struct _DEV_BROADCAST_OEM
    DWORD dbco_size;
    DWORD dbco_devicetype;
    DWORD dbco_reserved;
    DWORD dbco_identifier;
    DWORD dbco_suppfunc;

    • dbco_size Size of this structure, in bytes.
    • dbco_devicetype Set to DBT_DEVTYP_OEM.
    • dbco_reserved Reserved; do not use.
    • dbco_identifier OEM-specific identifier for the device.
    • dbco_suppfunc OEM-specific function value. Possible values depend on the device.

    I have overridden :
    bool MainWindow::winEvent ( MSG * message, long *){
    switch(message->message) {
    if( message->wParam == PBT_APMSUSPEND ){
    if( message->wParam == PBT_APMRESUMEAUTOMATIC ){
    case WM_KEYDOWN:
    if (message->wParam == DBT_DEVNODES_CHANGED) {
    // a device was added or removed.
    emit notifyDeviceChange();
    default: ;
    return false;
    where notifyDeviceChange(); is handled in some other class.

    I am not clear how to get a object or pointer to

    Second even if I get this object or pointer, how do i get the OS name ??


    edit: Please put code sections between @ tags; Andre

  • I'm not Robert :) anyway:

    in WM_POWERBROADCAST test for DBT_DEVICEARRIVAL if it is, the lParam will be then DEV_BROADCAST_HDR structure. Check for dbch_devicetype in this structure and if it equals to DBT_DEVTYP_OEM your lParam is the DEV_BROADCAST_OEM structure, just cast lParam to DEV_BROADCAST_OEM.

    also read about SetupDiGetDeviceInterfaceDetail WINAPI function.

    bq. Second even if I get this object or pointer, how do i get the OS name ??

    if OEM is "Apple iPhone bla bla", you have got iPhone, do more specific tasks with iPhone SDK to get OS version or whatever you need... If it is HTC, do the over stuff... and so on...

    You need to search on Specific Device devoplers forum for more information on how to get OS information for specified device. Qt and WINAPI can't help you here(WINAPI can help only for WM devices, maybe for WP too)

Log in to reply

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