Bluetoothapis.h windows SDK - Issue



  • Hello,

    I'm new to the Froum, so first of all, Hello all !

    I almost never post on forum before a lot of search, but here i'm blocked with something and i don't know how to success my problem.

    I actually want to use BluetoothApi from windows SDK, i checked the documentation and so, i try to use the BluetoothFindDirstDevice without any sucess.

    I mean i get no error inside Qt, but the program crash.

    Here is my code

    HBLUETOOTH_DEVICE_FIND hfind;
        hfind=NULL;
    
        BLUETOOTH_DEVICE_SEARCH_PARAMS params;
        params.dwSize=sizeof(BLUETOOTH_DEVICE_SEARCH_PARAMS);
    
        params.fReturnAuthenticated=true;
        params.fReturnConnected=true;
        params.fReturnUnknown=false;
        params.fReturnRemembered=true;
        params.fIssueInquiry=true;
        params.hRadio=NULL;
        params.cTimeoutMultiplier=5;
    
        BLUETOOTH_DEVICE_INFO btdi;
        ZeroMemory(&btdi,sizeof(BLUETOOTH_DEVICE_INFO));
        btdi.dwSize=sizeof(BLUETOOTH_DEVICE_INFO);
    
        hfind=BluetoothFindFirstDevice(&params,&btdi);
    
        if(hfind!=NULL)
        {
        qDebug()<<"We find a bt"   ;
        }else{
          qDebug()<<"Nothing"   ;
        }
    

    Qt 5.8 RC with minGW
    Windows 10 platform 64

    My Pro.file

    QT       += core gui
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    TARGET = BluetoothTest
    TEMPLATE = app
    
    INCLUDEPATH +="D:\WinSDK\Include"
    
    LIBS += "D:\WinSDK\Lib\10.0.14393.0\um\x86\WSock32.Lib"
    LIBS += "D:\WinSDK\Lib\10.0.14393.0\um\x86\bthprops.lib"
    
    
    SOURCES += main.cpp\
            mainwindow.cpp
    
    HEADERS  += mainwindow.h
    
    FORMS    += mainwindow.ui
    

    i don't know if you need more info to help me. if so ask me.

    Many thanks


  • Moderators

    Hi, welcome to the forum.

    You can't use Windows SDK provided by Microsoft with MinGW. It ships with its own, modified version of it. It probably compiles because you have errors in your config in the .pro file: \ is an escape character and that's not how you pass libraries to the linker.

    Remove the INCLUDEPATH. MinGW kit already has a path to its own version of Windows SDK. Also remove the LIBS paths and only add:

    LIBS += -lWSock32 -lbthprops
    

    Tthere's a -l(lowercase L) before the name of the lib and no .lib suffix.
    After that Build->run qmake and you should be good to go.



  • Awesome man.

    That show me that sometimes ask the question is more usefull than searching for hours....

    I didn't know that i could not use Windows SDK with MinGW i understand now. windows SDK needs to be with Visual compiler ...

    Many thanks have a nice Day.


  • Banned

    This post is deleted!


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