views:

343

answers:

2

Hi. Does anybody know how to change the COM port number that Windows maps to a USB virtual COM port? You can change this via the Device Manager and clicking on the Advanced button.. but how can you do this via an API, registry change or commandline operation?

Any ideas please?

A: 

Offhand, I don't know how to do it, but here's what I would do:

Use the My Computer/ Device Manager method to assign some unlikely com port, like 61. Then use regedit to search for COM61 and see what Device Manager did.

I know I've seen all these things in the registry somewhere, but a quick search of the knowledge base didn't turn up the answers.

wallyk
+1  A: 

You might find this answer useful:

http://stackoverflow.com/questions/304986/how-do-i-get-the-friendly-name-of-a-com-port-in-windows

It's about finding the friendly name, but I think you'll find it points you towards the right area of the registry, using the 'official' mechanism for locating the right key.

However, if you change the port assignment, you should also update the com port database - see: http://msdn.microsoft.com/en-us/library/ms800603.aspx

When I had to do something similar, I found the right device using the mechanism described in the linked SO article, and then called SerialDisplayAdvancedSettings((HWND)NULL, hDeviceInfo, &devInfoData); to display the advanced dialog and let the OS handle the hard work.

Nowadays you're more and more likely to be encountering odd 'not real' serial ports (e.g. USB ports) which might have other incompatibilities you need to be wary of too.

Will Dean
Thanks for this. Luckily the problem we have relates to an identical set of equipment and we only need a solution for this one type of PC. My collegue tried changing the registry as suggested below and we've managed to get it to work. I will be keeping your response safe though as it provides invaluable info for future use. Thanks to everybody who responded to this question.
SparkyNZ