简体   繁体   English

Java-如何知道打印机是否是网络打印机?

[英]Java - How to know if a printer is a network printer?

I know how to list all the printers installed in the OS: 我知道如何列出操作系统中安装的所有打印机:

PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null, null);

but a PrintService does not have information about the printer location. 但是PrintService没有有关打印机位置的信息。

Is there any way to see if a printer is a network printer? 有什么办法可以查看打印机是否是网络打印机? or has a share name? 或有一个共享名?

3 years later... 😱 三年后...😱

I used JNA and this extension to add PRINTER_INFO_2 support. 我使用了JNA此扩展来添加PRINTER_INFO_2支持。

Also, I used WinspoolExt.PRINTER_ENUM_LOCAL | WinspoolExt.PRINTER_ENUM_CONNECTIONS 另外,我使用WinspoolExt.PRINTER_ENUM_LOCAL | WinspoolExt.PRINTER_ENUM_CONNECTIONS WinspoolExt.PRINTER_ENUM_LOCAL | WinspoolExt.PRINTER_ENUM_CONNECTIONS as the flags. WinspoolExt.PRINTER_ENUM_LOCAL | WinspoolExt.PRINTER_ENUM_CONNECTIONS作为标志。

PRINTER_INFO_2.pShareName and PRINTER_INFO_2.pServerName have the information I needed. PRINTER_INFO_2.pShareNamePRINTER_INFO_2.pServerName包含我需要的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM