Sunday, June 17, 2007

How to check what serial ports are available in WM5/6?

I use the following code to check for available ports in Windows Mobile 5 and 6

[CODE]
private string[] GetAvailableCommPorts()
{
ArrayList commPorts = new ArrayList();
string port = "COM";
for (int i=1;i<=99;i++) { try { string portName = port+i.ToString()+":"; new OpenNETCF.IO.Serial.Port(portName).Query(); commPorts.Add(port+i.ToString()); } catch { } } return (string[]) commPorts.ToArray(typeof(string)); }

[/CODE]

No comments:

stats counter