0

My C# application populates a comboBox with the COM ports found on the system. I would like the mark the COM ports that are in use as such. I know that I can use try / catch blocks to attempt to open every COM port, but I was wondering if there is a more graceful way to do this. Perhaps using a WMI query? I am using Microsoft Visual C# 2008 Express Edition (.NET 2.0). Any thoughts or suggestions you may have would be appreciated. Thanks.

2 Answers 2

2

I'm not aware of any other method to do this. Attempting to open them is the way that native code does the same check.

Sign up to request clarification or add additional context in comments.

Comments

0

I know this a Old. But there is now a really easy way to do this. You can check if a port is open with:

if (serialPort1.IsOpen)
{
    ("Port Open");
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.