How can I disable Bluetooth connectability?

Jin Cheng 0 Reputation points
2026-09-30T01:59:00.2933333+00:00

I have a console application that enumerates all Bluetooth radios on the system and finds only one. I then call BluetoothEnableDiscovery(NULL, FALSE) followed by BluetoothEnableIncomingConnections(NULL, FALSE) for that radio. However, BluetoothIsConnectable(NULL) still returns TRUE.

test program:

#include <windows.h>
#include <bluetoothapis.h>
#include <stdio.h>
#pragma comment(lib, "Bthprops.lib")
int main()
{
    BLUETOOTH_FIND_RADIO_PARAMS params = {};
    params.dwSize = sizeof(params);
    HBLUETOOTH_RADIO_FIND hFind = NULL;
    HANDLE hRadio = NULL;
    hFind = BluetoothFindFirstRadio(&params, &hRadio);
    if (hFind == NULL)
    {
        printf("BluetoothFindFirstRadio failed: 0x%08X\n",
            GetLastError());
        return 1;
    }
    int radioCount = 1;
    // Check for additional Bluetooth radios.
    HANDLE hNextRadio = NULL;
    while (BluetoothFindNextRadio(hFind, &hNextRadio))
    {
        radioCount++;
        CloseHandle(hNextRadio);
        hNextRadio = NULL;
    }
    printf("Bluetooth radio count: %d\n", radioCount);
    if (radioCount != 1)
    {
        printf("Expected exactly one Bluetooth radio.\n");
        CloseHandle(hRadio);
        BluetoothFindRadioClose(hFind);
        return 1;
    }
    printf("\nInitial state:\n");
    BOOL discoverable = BluetoothIsDiscoverable(NULL);
    BOOL connectable = BluetoothIsConnectable(NULL);
    printf("  Discoverable: %s\n",
        discoverable ? "TRUE" : "FALSE");
    printf("  Connectable : %s\n",
        connectable ? "TRUE" : "FALSE");
    printf("\nDisable discovery:\n");
    SetLastError(ERROR_SUCCESS);
    BOOL ret = BluetoothEnableDiscovery(NULL, FALSE);
    printf("  BluetoothEnableDiscovery(NULL, FALSE): %s\n",
        ret ? "TRUE" : "FALSE");
    if (!ret)
        printf("  GetLastError: 0x%08X\n", GetLastError());
    printf("\nDisable incoming connections:\n");
    SetLastError(ERROR_SUCCESS);
    ret = BluetoothEnableIncomingConnections(NULL, FALSE);
    printf("  BluetoothEnableIncomingConnections(NULL, FALSE): %s\n",
        ret ? "TRUE" : "FALSE");
    if (!ret)
        printf("  GetLastError: 0x%08X\n", GetLastError());
    printf("\nFinal state:\n");
    discoverable = BluetoothIsDiscoverable(NULL);
    connectable = BluetoothIsConnectable(NULL);
    printf("  Discoverable: %s\n",
        discoverable ? "TRUE" : "FALSE");
    printf("  Connectable : %s\n",
        connectable ? "TRUE" : "FALSE");
    CloseHandle(hRadio);
    BluetoothFindRadioClose(hFind);
    printf("\nPress Enter to exit...");
    getchar();
    return 0;
}

console output:

Bluetooth radio count: 1
Initial state:
  Discoverable: FALSE
  Connectable : TRUE
Disable discovery:
  BluetoothEnableDiscovery(NULL, FALSE): FALSE
  GetLastError: 0x80070057
Disable incoming connections:
  BluetoothEnableIncomingConnections(NULL, FALSE): FALSE
  GetLastError: 0x80070057
Final state:
  Discoverable: FALSE
  Connectable : TRUE
Press Enter to exit...
Windows development | Windows API - Win32
0 comments No comments

1 answer

Sort by: Oldest
  1. Percy Nguyen (WICLOUD CORPORATION) 80 Reputation points Microsoft External Staff Moderator
    2026-09-30T02:48:48.23+00:00

    Hi @Jin Cheng ,

    Thank you for reporting this, and for including the detailed test program and output.  

    Looking at your output, BluetoothEnableIncomingConnections(NULL, FALSE) returned FALSE, which per the documentation means no radio accepted the state change. Your radio was already non-discoverable, so the documented ordering requirement is met, and something else is blocking the change. To narrow it down, could you try the following and share the results? 

    • Pass the radio handle explicitly. Use the hRadio returned by BluetoothFindFirstRadio instead of NULL for all four calls (BluetoothIsDiscoverable, BluetoothIsConnectable, BluetoothEnableDiscovery, BluetoothEnableIncomingConnections). Call BluetoothGetRadioInfo(hRadio, &info) first to confirm the handle is valid. 
    • Run the test from an elevated (administrator) prompt and compare the results with a non-elevated run. 
    • Close Settings > Bluetooth & devices before running the test, so nothing else is changing the radio state at the same time. 
    • Share your environment details: the Bluetooth adapter model, the driver version and provider (Device Manager > Bluetooth > adapter > Properties > Driver), and whether any paired devices are connected during the test. 

    I also noticed that your OS build, 26100.ge_release.240331, is a very early 24H2 baseline. I can't confirm that this build causes the assertion failure you're seeing. However, the HLK documentation notes that when a known issue in an HLK test or in Windows causes a test to fail incorrectly, an errata filters will be published to address it. And it is recommended using the HLK version that matches the Windows version under test. So updating the OS, using the matching kit, and applying the latest filters is a good way to rule this out. 

    So before you re-run, I suggest the following: 

    • Update the test system to the latest cumulative update for Windows 11, version 24H2. 
    • Use the HLK kit that matches that OS version.The 24H2 kit has been refreshed since its first release, so it's worth checking that your controller is on the current one. The kit downloads are listed on the Windows Hardware Lab Kit page. 
    • Install the latest HLK filters and playlist, then re-apply the filters to your existing results.Filters are how errata for known false failures get applied, and existing results aren't re-filtered automatically. The steps are in Windows Hardware Lab Kit Filters. 

    Looking forward to your update. If you found my response helpful or informative, I would greatly appreciate it if you could follow this guide for your confirmation. 

    Thank you.

     

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.