如何从 Java 访问 Windows 设备管理器中的信息? [英] How to access information in Windows Device Manager from Java?

查看:71
本文介绍了如何从 Java 访问 Windows 设备管理器中的信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个串行转 USB 设备,其中不止一个可以连接到计算机.我需要查询和检索设备连接到的 COM 端口列表.在 Windows 设备管理器中,您可以获得当前连接的设备的 COM 端口 + 友好名称.此列表是动态的.

I have a serial to USB device and more than one of those can be connected to the computer. I need to query and retrieve a list of COM ports that the devices are connected to. In Windows Device Manager you can get the COM port + friendly name of devices that are connected at the present time. This list is dynamic.

从注册表读取没有工作,因为存储的信息是陈旧和静态的,而不是动态的.

Reading from the registry did not work because the information stored is stale and static, not dynamic.

Devcon(来自 Microsoft)确实列出了设备连接到的端口,但它不能在我的应用程序中使用,因为它不可重新分发.

Devcon (from Microsoft) does list the ports that devices are connected to, but it cannot be used in my app because it is not re-distributable.

任何想法或最好的解决方案?

Any ideas or preferably, a solution?

推荐答案

我在看 Java Native Access 因为它提供了从纯 Java 代码访问 Windows API 的能力 - 无需处理 JNI.我担心 LGPL 许可证;它是否可以包含在商业产品中,但从新闻组中的一些帖子说,它可以.在接下来的几周内试用后,我会在此处发布.

I am looking at Java Native Access as it provides access to the windows API from pure Java code - no JNI to deal with. I was concerned about the LGPL license; whether it can be included in a commercial product but from what a few posts in the newsgroup say, it can be. After I try it out in the next few weeks, I shall post back here.

这篇关于如何从 Java 访问 Windows 设备管理器中的信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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