SerialPort.GetPortNames() 未返回正确的结果

发布于 2024-09-08 18:31:24 字数 508 浏览 3 评论 0原文

我正在为 Windows Mobile 6.1 开发小型演示应用程序,以获取所有串行端口及其上配置的蓝牙设备的列表。我面临一些奇怪的问题。

  1. 当我进入“设置”->“连接”->“蓝牙”->“COM 端口”时,我可以看到总共 10 个 COM 端口。但是当我使用 SerialPort.GetPortNames() 获取所有端口时,它显示 9 个端口,即少一个端口。最后一个端口(即 COM09)不会在结果集中返回。

  2. 然后我删除了在其中一个 COM 端口 (COM08) 上配置的配对设备之一,并且 SerialPort.GetPortNames() 返回了没有 COM08 端口的结果集。

  3. 我进一步尝试了解哪些 COM 端口仍未使用。当我尝试在“未使用”(根据我的程序)端口之一手动创建“新传出端口”时,它会显示一条消息“无法创建 COM 端口”!

有人可以告诉我原因并指导我进一步解决问题吗?

I'm developing small demo application for Windows Mobile 6.1 to get the list of all serial ports and the Bluetooth devices configured on them. I'm facing some weird problem.

  1. I can see total 10 COM ports when I go to Settings->Connections->Bluetooth->COM POrts. But when I use SerialPort.GetPortNames() to get all the ports, it shows 9 ports i.e. one port less. The last port i.e. COM09 is not returned in the result set.

  2. Then I removed one of the paired devices configured on one of the COM ports (COM08) and SerialPort.GetPortNames() returned the result set WITHOUT the COM08 port.

  3. I further tried to know which COM ports are still unused. When i tried to create "New Outgoing Port" manually on one of the 'unused' (as per my program) port, it gives a message saying "COM port cannot be created"!

Could someone tell me the reason and guide me further to resolve the issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

伴梦长久 2024-09-15 18:31:24

蓝牙驱动程序可能正在修改驱动程序所在的注册表项,并且 GetPortNames 可能正在查找该注册表项。

使用删除注册表编辑器查看 HKLM\Drivers\BuiltIn 和 HKLM\Drivers\Active,看看发生了什么。您可以编写自己的解析器来查看这些值以了解您想要的内容。

The Bluetootch driver is probably modifying the registry key where the Drivers are and GetPortNames is probably looking through that key.

Take a look at both HKLM\Drivers\BuiltIn and HKLM\Drivers\Active with the remove registry editor and see what's happening. You can likely write your own parser that looks at these values for what you are after.

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