简体   繁体   English

JAVA从所有Windows用户帐户检索所有打印机

[英]JAVA retrieve all printers from all windows user accounts

Is there any way to retrieve all the printers installed by various windows user accounts on same machine. 有什么方法可以检索同一计算机上各种Windows用户帐户安装的所有打印机。

lookupPrintServices() method of the javax.print.PrintServiceLookup class displays all the printers which can be seen in the Control Panel in Windows for logged in user. javax.print.PrintServiceLookup类的lookupPrintServices()方法显示所有打印机,这些打印机可以在Windows的“控制面板”中为登录用户显示。

It will help 我会帮你的

import javax.print.PrintService;
import javax.print.PrintServiceLookup;


public class CheckInstalledPrinter {
    public static void main (String [] args)
    {
        PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null, null);
        System.out.println("Total Services :: " + printServices.length);

        for (PrintService printer : printServices)
            System.out.println("Printer Name :: " + printer.getName()); 
    }
}

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

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