简体   繁体   中英

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.

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.

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()); 
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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