【发布时间】:2016-08-26 10:16:48
【问题描述】:
下面是我正在尝试的代码 sn-p:
PRINTER_INFO_2 pi;
BOOL Result = FALSE;
HANDLE pHd;
memset(&pi, 0, sizeof(PRINTER_INFO_2));
pi.pPrinterName = L"RxXPSDrv";
pi.pDriverName = L"XPSDrv Sample Driver";
// Select Share Name
pi.pShareName = L"MyPrinter";
// Select Server Name
pi.pServerName = NULL;
// Select Port Name
pi.pPortName = L"COM3:";
//pi.pPortName = L"C:\\Users\\admin\\Desktop\\a1.xps";
pi.pSecurityDescriptor = NULL;
// Select Print Processor
pi.pPrintProcessor = L"winprint";
// Select Attributes
pi.Attributes = PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST | PRINTER_ATTRIBUTE_LOCAL;
// Set Priority
pi.Priority = 1;
// Call the function AddPrinter
pHd = AddPrinter(NULL, 2, (LPBYTE)&pi);
这里 @pi.pPortName 我需要提供 C:\Users\admin\Desktop\a1.xps 但它不起作用并且打印机没有被添加. COM3 可以正常工作。 谁能告诉我我该怎么做?如何提供 XPS 到 pi.pPortName 的完整路径?
【问题讨论】:
标签: c++ windows winapi printers