通过注册表、命令行或软件更改 COM 端口?
有谁知道如何更改Windows映射到USB虚拟COM端口的COM端口号?您可以通过设备管理器并单击“高级”按钮来更改此设置。但是如何通过 API、注册表更改或命令行操作来执行此操作?
有什么想法吗?
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 command line operation?
Any ideas please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我在将 COM 端口 1 更改为 110 期间监视了注册表更改,发现以下项发生了修改:
I monitored registry changes during changing COM port 1 to 110 and found modifications in following keys:
您可能会发现这个答案很有用:
如何在 Windows 中获取 COM 端口的友好名称?
这是关于查找友好名称,但我认为您会发现它使用“官方”机制将您指向注册表的正确区域用于找到正确的密钥。
但是,如果更改端口分配,还应该更新 com 端口数据库 - 请参阅:https://msdn.microsoft.com/en-us/library/ff546481.aspx
当我必须做类似的事情时,我使用链接的 SO 文章中描述的机制找到了正确的设备,然后称为 SerialDisplayAdvancedSettings((HWND)NULL, hDeviceInfo, &devInfoData);显示高级对话框并让操作系统处理繁重的工作。
如今,您越来越有可能遇到奇怪的“非真实”串行端口(例如 USB 端口),它们可能存在其他不兼容性,您也需要警惕。
You might find this answer useful:
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: https://msdn.microsoft.com/en-us/library/ff546481.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.
此更改是通过“regedit”在注册表中通过以下两个步骤完成的:
更改名称:
第一步,您需要更改以下键:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\XXX
中,XXX 是您的设备名称。您需要跟踪每个项目以找到FriendlyName
,然后根据需要进行更改(例如:“USB 串行端口 (6)”);PortName
并将其更改为端口号(例如:“COM6”)。更改端口号:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\COM Name Arbiter
中,您可以找到ComDB
,它是已分配的COM端口的位掩码。该值应根据您的 COM 端口进行更改。注:第一个字节控制 COM8~1,第二个字节控制 COM16~9,第三个字节控制 COM24~COM17,以此类推。值=0 表示该端口未被使用。 value=1表示端口被占用。This changing is done in two below steps in the registry through the "regedit":
Change the name:
In the first step, you need to change the below keys:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\XXX
that XXX is your device name. You need to trace each item to find theFriendlyName
and then change it as you wish (Ex: "USB Serial Port (6)");PortName
and change it to the port number (Ex: "COM6").Change the port number:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\COM Name Arbiter
, you can find theComDB
which is a bit mask of COM ports already allocated. This value should be change based on your COM ports. Note, The first byte controls COM8~1, the second byte controls COM16~9, the third byte controls COM24~COM17 and so on. A value=0 means that the port is not used. A value=1 means that the port is occupied.顺便说一句,我不知道该怎么做,但我会这样做:
使用我的电脑/设备管理器方法分配一些不太可能的 com 端口,例如 61。然后使用 regedit 搜索 COM61 并查看设备管理器做了什么。
我知道我已经在注册表中的某个地方看到了所有这些内容,但是快速搜索知识库并没有找到答案。
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.