To get all available Serialports from the system, I use the following command.
SerialPort.GetPortNames
It works fine for the serial port of the motherboard, but with the Bluetooth device I get the wrong port names.
For example: instead of COM7, I sometimes get COM70 or COM7ΓΆ. Its always 1 letter.
any assumptions?
PS: I use the latest Visual Studio Express in Windows 7 PPS: dirty hacking the last letter did not work, because I donβt know which one is a bluetooth serial port (with various bluetooth plugs or devices that change the number of commots), and after of how I tried various sticks, I reached COM10, ergo COM100 or COM10f
EDIT: The code I'm using right now. reading registers, but still the same problem.
RegistryKey myRegistry = Registry.LocalMachine.OpenSubKey("Hardware\\DeviceMap\\SerialComm"); foreach (string valuename in myRegistry.GetValueNames()) { if (myRegistry.GetValue(valuename) is String) { if (valuename.Contains("BthModem")) { richTextBox1.AppendText(">" + myRegistry.GetValue(valuename) + "<" + Environment.NewLine); } } }
Usually the second or third query works with a result like
COM11α― <COM10S <COM11 <COM10 <COM11 <COM10 <
how can it be?
c # bluetooth serial-port
wurlog
source share