views:

213

answers:

2

How to programmatically associate a name like COM51 to a physical serial port in Microsoft Windows?

To manually perform the operation I can follow the steps described in
link text

Open Device Manager with devmgmt.msc

Double-click Ports (COM & LPT).

Right-click the port I want, and then click Properties.

On the Port Settings tab, if I want to change the COM port number (for example, from COM1 to COM51), I click the Advanced button, and then select the COM port number I need from the list.

But, how can I do the job with a program? Is there an API to do the job? Thank you.

+1  A: 

I don't know any API to achieve that, but you can edit the registry values under HKLM\Hardware\DEVICEMAP\SERIALCOMM

Juanma
A: 

ComDBClaimPort http://msdn.microsoft.com/en-us/library/ms800845.aspx

That only does part of the job though.

Windows programmer