开发者

Programmatically change a com port

开发者 https://www.devze.com 2023-02-19 14:47 出处:网络
I am trying to create a program to switch the com port number of currently attached device. For example, I have a device assigned to com port number 5, and I want to change it to maybe com port number

I am trying to create a program to switch the com port number of currently attached device. For example, I have a device assigned to com port number 5, and I want to change it to maybe com port number 20. How do I go about doing it? Is there any referenc开发者_C百科e tutorial, etc that I can build on?


We seem to be working on similar problems. AFAIK there are two possible approaches to this problem. The first being directly manipulating the com port environment within Windows (quite tricky), the second one being the changing of the parameters of those com port-related drivers that allow for that kind of parameter change directly within their respective driver environment (rather easy).

Here is one example for a com port-related driver parameter change (actually they almost all look the same, at least those that I have encoutered so far):

1.) detach device (physically or logically / Microsoft DEVCON could do that for you)

2.) stop driver service

3.) change registry key [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\VID_****&PID_****&MI_**{device instance id (DIID)}\Device Parameters] "PortName"="COM123"

4.) reattach device (physically or logically / Microsoft DEVCON could do that for you)

5.) start driver service

PS: Please let me know if you find a good solution to the problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号