I need to determine the COM-Port of a Plug-And-Play-Device. I have the PnPDeviceID. It's a bluetooth usb dongle.
So, I retrieve information about the device using WMI like in the first example at this website. The result of the WMI-query contains a property "DeviceID" which is a string. The value in my case is "COM3".
I get the same value, when I do (instead of using WMI)
string[] names = System.IO.Ports.SerialPort.GetPortNames();
Now I am wondering, if the DeviceId of COM-Devices always has the format "COMx"? I actually need a property called "Port" with an integer as value.
There is another approach, to go over the registry, but I don't know, if this is suggested.
int Port
– OneWorld