Printer Checker

I am looking for a way to check if a printer exists on a Linux / Unix machine using a C or C ++ program. Something like the following windows program:

BOOL IsPrinterExist(LPTSTR pPrinterName) { HANDLE hPrinter = NULL; if(OpenPrinter(PRINTERNAME,&hPrinter,NULL)) { ClosePrinter(hPrinter); hPrinter = NULL; return TRUE; } return FALSE; } 

I think I can do this using the CUPS API, but I need something that will work on each machine without special installations using the OS API. I know that I can also use the lpstat -a command and read its output, but I am looking for a way to do this directly (which does lpstat -a ).

+4
source share
1 answer

Since CUPS is the de facto standard for printing on GNU / Linux systems, I would not worry too much about โ€œspecial settingsโ€: if CUPS is not installed, the machine will probably not be able to print anyway.

To learn how to use the CUPS API, see lpstat source .

+1
source

Source: https://habr.com/ru/post/1485260/


All Articles