本文介绍了在 Delphi 中枚举系统 Com 端口列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目标:我希望能够在 Delphi 中列出系统上可用的 COM 端口.

Objective: I would like to be able to list the available COM Ports on a system in Delphi.

家庭作业:我已阅读 this SO thread on enumifying the LPT使用注册表的系统端口.我还发现 COM 端口列在 HKEY_LOCAL_MACHINEHARDWAREDEVICEMAPSERIALCOMM 的注册表中,但在 同一个线程,这在不同的机器和不同版本的 Windows 上可能不可靠.

Homework:I have read this SO thread on enumerating the LPT ports of a system using the registry. I have also found that the COM ports are listed in the registry at HKEY_LOCAL_MACHINEHARDWAREDEVICEMAPSERIALCOMM but found unanswered gesticulation in the same thread that this might not be reliable on different machines and different versions of windows.

我还发现文章引用了 QueryDosDevice() 的使用,但在尝试 this示例代码,我发现它似乎根本没有列出任何 COM 端口.

I also found articles referencing the use of QueryDosDevice() but upon trying this sample code, I found that it did not appear to list any COM ports at all.

问题:列出 Windows 机器上的 COM 端口最可靠的方法是什么(跨未知的 Windows 版本)?

Question: What is the most reliable way (across unknown Windows Versions) to list the COM ports on a Windows Machine?

推荐答案

DEVICEMAPSERIALCOMM 适用于所有 NT 版本.您可能需要在 DYN_DATA 下查看 Win9x.

DEVICEMAPSERIALCOMM is good for all NT versions. You'll probably need to look under DYN_DATA for Win9x.

如果您需要运行时可靠性,请使用此方法.

Use this method if you need runtime reliability.

这篇关于在 Delphi 中枚举系统 Com 端口列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-28 19:47
查看更多