gpt4 book ai didi

java - 如何在java中获取默认打印机端口号

转载 作者:行者123 更新时间:2023-12-04 07:06:51 25 4
gpt4 key购买 nike

我想访问 Java 中的默认打印机端口。

另外,我想知道默认打印机是喷墨、激光、点阵等。
请提供引用。

最佳答案

我猜你正在使用windows。在这种情况下,您可以查询 Windows 注册表以查找默认打印机端口。所有的系统信息都是 Preferences。

import java.util.prefs.Preferences;

....

Preferences userRoot = Preferences.userRoot();
Preferences systemRoot = Preferences.systemRoot();

有一篇很好的文章解释了如何使用 来做到这一点。纯 java :

http://lenkite.blogspot.com/2008/05/access-windows-registry-using-java.html?dzref=85420

此外,您可能需要知道 Windows 中默认打印机的 key :
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows

关于java - 如何在java中获取默认打印机端口号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1001418/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com