Do you want to know if the device is attached via serial OR usb, or you want to find any devices attached to either port type?
You can probably accomplish that using something from the WMI libraries.
Look for something called "WMICodeCreator", its really usefull for playing around and seeing what you can find.
For example using WIn32_PnPEntity it made this code:
-
using System;
-
using System.Management;
-
using System.Windows.Forms;
-
-
namespace WMISample
-
{
-
public class MyWMIQuery
-
{
-
public static void Main()
-
{
-
try
-
{
-
ManagementObjectSearcher searcher =
-
new ManagementObjectSearcher("root\\CIMV2",
-
"SELECT * FROM Win32_PnPEntity");
-
-
foreach (ManagementObject queryObj in searcher.Get())
-
{
-
Console.WriteLine("-----------------------------------");
-
Console.WriteLine("Win32_PnPEntity instance");
-
Console.WriteLine("-----------------------------------");
-
Console.WriteLine("Caption: {0}", queryObj["Caption"]);
-
Console.WriteLine("Description: {0}", queryObj["Description"]);
-
Console.WriteLine("DeviceID: {0}", queryObj["DeviceID"]);
-
}
-
}
-
catch (ManagementException e)
-
{
-
MessageBox.Show("An error occurred while querying for WMI data: " + e.Message);
-
}
-
}
-
}
-
}
-
Producing something like:
Win32_PnPEntity instance
-----------------------------------
Caption: 802.11n USB Wireless LAN Card - Deterministic Network Enhancer Miniport
Description: Deterministic Network Enhancer Miniport
DeviceID: ROOT\DNI_DNEMP\0007
-----------------------------------
Win32_PnPEntity instance
-----------------------------------
Caption: 802.11n USB Wireless LAN Card - Virtual Machine Network Services Driver
Description: Virtual Machine Network Services Driver
DeviceID: ROOT\CNTX_VPCNETS2_MP\0004
-----------------------------------
Win32_PnPEntity instance
-----------------------------------
Caption: 802.11n USB Wireless LAN Card - Packet Scheduler Miniport
Description: Packet Scheduler Miniport
DeviceID: ROOT\MS_PSCHEDMP\0007