How to distinguish USB to serial converters?

I have 4 USB-to-serial converters (Prolific) connected to a USB hub. When I look in the device manager, I see dynamically assigned Com numbers. But after replacing the hub with another USB port or after rebooting the system, these com numbers sometimes change. Is there a way to update these numbers for each converter without manually searching for these numbers? Basically, I would like to have a method in my C # project that will look for some unique identifier for each converter, and then get the new com numbers. Is there a way to do this (tried some wmi requests, but to no avail)?

Today I thought of a workaround. So I got another question. How to get usb host information? Basically, I could somehow find my USB hub, and then get information about connecting the hub ports to the devices. Then it will be quite easy to get the com numbers of these devices through a wmi request. I used USBView to see that such information is available. I see a tree starting with Root Hub -> Generic USB Hub -> Prolific USB-to-serial Comm Port, but how to do it in code now. Any ideas?

+4
source share
1 answer

Simple, using your own win32 calls, you can get

I just provide a piece of code to help you,

var guidComPorts = Guid.Empty; UInt32 dwSize; IntPtr hDeviceInfo; var buffer = new byte[512]; var providerName = new[] { }; var spddDeviceInfo = new SpDevinfoData(); var bStatus = SetupDiClassGuidsFromName("Ports", ref guidComPorts, 1, out dwSize); if (bStatus) { hDeviceInfo = SetupDiGetClassDevs( ref guidComPorts, (IntPtr)null, (IntPtr)null, DigcfPresent | DigcfProfile); if (hDeviceInfo.ToInt32() != 0) { while (true) { spddDeviceInfo.CbSize = Marshal.SizeOf(spddDeviceInfo);// IS IT THIS LINE WORK FOR 64 BIT bStatus = SetupDiEnumDeviceInfo(hDeviceInfo, nDevice++, ref spddDeviceInfo); break; } } return; } } 

Use this code ...

find friendly names, split the string get the exact port you are looking for. I completed it, it works fine due to some reason of confidentiality, cannot provide the full code here.

Read more Find this link

http://www.codeproject.com/KB/cs/HardwareHelper.aspx

+1
source

All Articles