在win32下操作printer:
1)import win32print
2) 获得默认打印机名:
>>> win32print.GetDefaultPrinter()
'Canon LBP-800'
3)打开一个指定的打印机并获得其句柄
>>> handle = win32print.OpenPrinter('Canon LBP-800')
4)获得一个指定的打印机句柄所对应的打印机的信息
>>> win32print.GetPrinter(handle)
(None, 'Canon LBP-800', '', 'LPT1:', 'Canon LBP-800', '', '', None, '', 'W
inPrint', 'RAW', '', None, 2624, 1, 0, 0, 0, 0, 0, 0)
5)关闭打印机
>>> win32print.ClosePrinter(handle)
5)枚举打印机,呵呵,看看MSDN,琢磨一下flag对应的几个位
>>> win32print.EnumPrinters(2)
((8388608, '\264\253\325\346,Windows NT Fax Driver,', '\264\253\325\346',
''), (8388608, 'FinePrint 2000,FinePrint 2000,', 'FinePrint 2000', ''), (838
8608, 'Canon LBP-800,Canon LBP-800,', 'Canon LBP-800', ''), (8388608, 'Acrob
at PDFWriter,Acrobat PDFWriter,', 'Acrobat PDFWriter', ''), (8388608, 'Acrob
at Distiller,AdobePS Acrobat Distiller,', 'Acrobat Distiller', ''))
>>> win32print.EnumPrinters(8)
((98304, 'Windows NT Local Printers', 'Windows NT Local Print Providor', '
Locally connected Printers'), (114688, 'Microsoft Windows Network', 'Windows
NT \324\266\263\314\264\362\323\241\273\372', '\324\266\263\314\264\362\323
\241\273\372'), (16875520, 'Windows NT Internet Printing', 'Windows NT Inter
net Provider', 'Internet URL Printers'))