Get the name of a Bluetooth device in the Devices and Printers window

I know that there are issues related to collecting the device friendly name in the Device Manager, but I can’t do this, because the device is simply called "Stardard Serial over Bluetooth link (COM)" and I have many virtual ports with the same link. I want the device name to appear in the "Devices and Printers" window:

How to get the device name from here

I do this in C # and currently just get a list of available COM ports on the system and select the one I know from memory.

+1
c # visual-studio bluetooth
source share
3 answers

I managed to get it working using 32Feet.Net .

You can search for a device by doing

BluetoothClient client = new BluetoothClient(); devices = client.DiscoverDevicesInRange(); foreach (BluetoothDeviceInfo d in devices) { items.Add(d.DeviceName); } 

This will give a list of friendly names that you see in the "Devices and Printers" window, and not "Standard Bluetooth Serial Number."

If you need a COM port, for example, me or any other information, you can simply execute a WMI request, for example

  System.Management.ManagementObjectSearcher Searcher = new System.Management.ManagementObjectSearcher("Select * from WIN32_SerialPort"); foreach (System.Management.ManagementObject Port in Searcher.Get()) { //your comparison or code here } 
+1
source share

I use my own code using the 32feet.Net Library, which helps me get the device friendly name and COM port information that is attached to this device in the C # console application.

I use the code below to identify a Topaz-Signature device and its friendly name is "T-S460-BT2". You can replace this

string FriendlyDeviceName = "T-S460-BT2";

in the code with the name of your device that you want to find.

 using InTheHand.Net; using InTheHand.Net.Bluetooth; using InTheHand.Net.Bluetooth.Widcomm; using InTheHand.Net.Sockets; using System; using System.Collections.Generic; using System.Linq; using System.Management; using System.Text; using System.Text.RegularExpressions; namespace SearchDevice { class Program { static void Main(string[] args) { string FriendlyDeviceName = "T-S460-BT2"; if (BluetoothRadio.IsSupported) { BluetoothClient client = new BluetoothClient(); BluetoothDeviceInfo[] devices; devices = client.DiscoverDevicesInRange(); foreach (BluetoothDeviceInfo d in devices) { if (Regex.IsMatch(d.DeviceName, FriendlyDeviceName, RegexOptions.IgnoreCase)) { try { string query = string.Format("SELECT Name, DeviceID, PNPDeviceID from WIN32_SerialPort"); ManagementObjectSearcher searcher = new ManagementObjectSearcher(query); ManagementObjectCollection osDetailsCollection = searcher.Get(); foreach (ManagementObject mo in osDetailsCollection) { string PNPDeviceID = (string)mo.GetPropertyValue("PNPDeviceID"); if (PNPDeviceID != null && Regex.IsMatch(PNPDeviceID, d.DeviceAddress + "", RegexOptions.IgnoreCase)) { Console.WriteLine("{0}", ((string)mo.GetPropertyValue("DeviceId")).Replace("COM", "")); } } } catch (Exception exx) { } } } } else { Console.WriteLine("Not Supported"); } Console.ReadLine(); } } } 
0
source share

I managed to get the name, Bluetooth address and COM port number without using the 32feet.net library by going to the registry section.

Then you can connect the Bluetooth device using the SerialPort class by passing the COM port number.

The pseudo code for getting bluetooth information is below:

  • list all COM port available in PNP
  • get deviceGuid class
  • find bluetooth address from guid class
  • when the Bluetooth address is known, the Bluetooth name can be obtained from this registry SYSTEM\CurrentControlSet\Services\BTHPORT\Parameters\Devices

I posted my code at the link below:

fooobar.com/questions/424098 / ...

0
source share

All Articles