枚举Delphi中的系统端口列表 [英] Enumerating a List of systems Com Ports in Delphi

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

问题描述

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

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

家庭作业:
我已阅读这个 SO线程,使用注册表枚举系统的LPT端口。我还发现,COM端口在注册表中列出 HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM ,但在同一个线程,这可能不可靠不同的机器和不同版本的窗口。

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_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM but found unanswered gesticulation in the same thread that this might not be reliable on different machines and different versions of windows.

我还发现引用使用QueryDosDevice()但是尝试这个示例代码,我发现它似乎没有列出任何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?

推荐答案

DEVICEMAP\SERIALCOMM 适用于所有NT版本。您可能需要在DYN_DATA下查找Win9x。

DEVICEMAP\SERIALCOMM 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中的系统端口列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆