0

任何人都知道使用 获取打印机 URICUPS API吗?

如果没有,有谁知道我在哪里可以找到可以传递给的允许选项列表cupsGetOption function

现在我只能找到printer-info, printer-location, printer-make-and-model.

4

1 回答 1

2

您可能正在寻找的是“device-uri”。这是远程设备的 uri,即 lpd/socket/服务器地址。如果您正在寻找本地 uri,它将是“printer-uri-supported”,这将导致 ipp://localhost:631/printers/printername。这是获取远程uri的方法...

#import <cups/cups.h>

const char * printer = "name_of_printer";
int num_dests;
cups_dest_t *dest,
            *dests;

const char *value;

num_dests = cupsGetDests(&dests);
dest = cupsGetDest(printer, NULL, num_dests, dests);
if( dest == NULL){
    return 0;
};
value = NULL;

if (dest->instance == NULL)
{
    value = cupsGetOption("device-uri", dest->num_options, dest->options);
}

cupsFreeDests(num_dests, dests);
printf("uri - %s",value);
于 2014-03-03T14:13:36.357 回答