Bluetooth Toggle By nature I'm lazy, I'll spend hours writing applications so I can shave mere seconds off repetitive tasks. To that end I'm looking to write an application that when launched will toggle the bluetooth state. I've looked at the Broadcom/Widcomm SDK but they don't seem to expose any methods to disable/enable the radio.
I've determined that the "StackMode" registry key at HKEY_LOCAL_MACHINE\Software\Widcomm\BtConfig\Gener al controls the bluetooth state when the stack is loaded (0 = off, 1 = on, 2 = discoverable? [not sure about 2]).
It appears as though BTTray.exe loads the BT stack.
At first it looked like it'd be as simple as:
1. Kill BTTray.exe
2. StackMode = StackMode == 0 ? 1 : 0
3. Launch BTTray.exe
This seems to work fine if the device booted with Bluetooth turned off and it has never been started. However once the stack has been loaded once this process results in an error message: "There was an error loading the Bluetooth Stack (0x1).", everytime BTTray.exe is loaded and BT stops working until the device is reset.
Seems like something else is holding onto, and keeping open, the BT stack but I'm not sure what. Any suggestions are greatly appreciated. |