[英]How to rename a printer in C++ on Windows?
在WinSpool.h中,我可以使用EnumPrinters函数枚举所有打印机,但是找不到如何重命名现有打印机?
You can use the SetPrinter
function to rename a printer. 您可以使用
SetPrinter
函数来重命名打印机。
You would set the Level
parameter to 2
and the pPrinter
parameter would point to a PRINTER_INFO_2
structure. 您可以将
Level
参数设置为2
,而pPrinter
参数将指向PRINTER_INFO_2
结构。 The PRINTER_INFO_2::pPrinterName
field lets you change the printer name. PRINTER_INFO_2::pPrinterName
字段使您可以更改打印机名称。
Note that the docs for SetPrinter
say: 请注意,
SetPrinter
的文档说:
To modify the current printer settings, call the GetPrinter function to retrieve the current settings into a PRINTER_INFO_2 structure, modify the members of that structure as necessary, and then call SetPrinter .
要修改当前打印机设置,请调用GetPrinter函数以将当前设置检索到PRINTER_INFO_2结构中,根据需要修改该结构的成员,然后调用SetPrinter 。
So you would need to call GetPrinter
with a properly initialized structure first, before modifying the name and calling SetPrinter
. 因此,您需要先使用正确初始化的结构调用
GetPrinter
,然后再修改名称并调用SetPrinter
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.