c# - Why GetPortNames method returns nothing? -
i trying send sms computer cell phone. first step: com ports use it. used code, no benefit:
private void form1_load(object sender, eventargs e) { string[] ports = serialport.getportnames(); foreach (string prt in ports) { combobox1.items.add(prt); } }
it returns nothing. can do?
i ran following code on pc , returns "com1":
string[] ports = serialport.getportnames(); console.writeline("the following serial ports found:"); foreach(string port in ports) { console.writeline(port); } console.readline();
so, it's either permissions or don't have serial ports. or perhaps registry corrupt?
note:
the port names obtained system registry (for example, hkey_local_machine\hardware\devicemap\serialcomm). if registry contains stale or otherwise incorrect data getportnames method return incorrect data.
Comments
Post a Comment