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(); } } }
Waqas ahmed
source share