通过注册表、命令行或软件更改 COM 端口?

发布于 2024-08-16 23:40:55 字数 114 浏览 2 评论 0原文

有谁知道如何更改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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

晨敛清荷 2024-08-23 23:40:55

我在将 COM 端口 1 更改为 110 期间监视了注册表更改,发现以下项发生了修改:

[HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM]
“\Device\Serial0”=“COM110”

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\COM 名称仲裁器]
"ComDB"=十六进制(3):FC,7F,00,00,00,00,00,00,00,00,00,00,00,20,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\ACPI\PNP0501\1\设备参数]
“端口名称”=“COM110”

I monitored registry changes during changing COM port 1 to 110 and found modifications in following keys:

[HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM]
"\Device\Serial0"="COM110"

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\COM Name Arbiter]
"ComDB"=hex(3):FC,7F,00,00,00,00,00,00,00,00,00,00,00,20,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\ACPI\PNP0501\1\Device Parameters]
"PortName"="COM110"

牵强ㄟ 2024-08-23 23:40:55

您可能会发现这个答案很有用:

如何在 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.

你的背包 2024-08-23 23:40:55

此更改是通过“regedit”在注册表中通过以下两个步骤完成的:

  1. 更改名称:
    第一步,您需要更改以下键:

    1. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\XXX 中,XXX 是您的设备名称。您需要跟踪每个项目以找到 FriendlyName,然后根据需要进行更改(例如:“USB 串行端口 (6)”);
    2. 在上一个密钥中,您再次需要跟踪该项目以找到 PortName 并将其更改为端口号(例如:“COM6”)。
  2. 更改端口号:

    1. 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":

  1. Change the name:
    In the first step, you need to change the below keys:

    1. In the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\XXX that XXX is your device name. You need to trace each item to find the FriendlyName and then change it as you wish (Ex: "USB Serial Port (6)");
    2. In the previous key, again you need to trace the item to find the PortName and change it to the port number (Ex: "COM6").
  2. Change the port number:

    1. In the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\COM Name Arbiter, you can find the ComDB 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.
心凉怎暖 2024-08-23 23:40:55

顺便说一句,我不知道该怎么做,但我会这样做:

使用我的电脑/设备管理器方法分配一些不太可能的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文