python学习笔记(win32print API介绍)
最近博主在研究用python控制打印机
这里整理下win32print的API介绍,官网地址http://timgolden.me.uk/pywin32-docs/win32print.html
OpenPrinter 打开指定的打印机,并获取打印机的句柄
GetPrinter 取得与指定打印机有关的信息
SetPrinter 对一台打印机的状态进行控制
ClosePrinter 关闭一个打开的打印机对象
AddPrinterConnection 连接指定的打印机
DeletePrinterConnection 删除与指定打印机的连接
EnumPrinters 枚举系统中安装的打印机
GetDefaultPrinter 取得默认打印机名称 <type 'str'>
GetDefaultPrinterW 取得默认打印机名称 <type 'unicode'>
SetDefaultPrinter 对一台打印机名称 <type 'str'> 设置成默认打印机
SetDefaultPrinterW 对一台打印机名称 <type 'unicode'> 设置成默认打印机
StartDocPrinter 在后台打印的级别启动一个新文档
EndDocPrinter 在后台打印程序的级别指定一个文档的结束
AbortPrinter 删除与一台打印机关联在一起的缓冲文件
StartPagePrinter 在打印作业中指定一个新页的开始
EndPagePrinter 指定一个页在打印作业中的结尾
StartDoc 开始一个打印作业
EndDoc 结束一个成功的打印作业
AbortDoc 取消一份文档的打印
StartPage 打印一个新页前要先调用这个函数
EndPage 用这个函数完成一个页面的打印,并准备设备场景,以便打印下一个页
WritePrinter 将发送目录中的数据写入打印机
EnumJobs 枚举打印队列中的作业
GetJob 获取与指定作业有关的信息
SetJob 对一个打印作业的状态进行控制
DocumentProperties 打印机配置控制函数
EnumPrintProcessors 枚举系统中可用的打印处理器
EnumPrintProcessorDatatypes 枚举由一个打印处理器支持的数据类型
EnumPrinterDrivers 枚举指定系统中已安装的打印机驱动程序
EnumForms 枚举一台打印机可用的表单
AddForm 为打印机的表单列表添加一个新表单
DeleteForm 从打印机可用表单列表中删除一个表单
GetForm 取得与指定表单有关的信息
SetForm 为指定的表单设置信息
AddJob 用于获取一个有效的路径名,以便用它为作业创建一个后台打印文件。它也会为作业分配一个作业编号
ScheduleJob 提交一个要打印的作业
DeviceCapabilities 利用这个函数可获得与一个设备的能力有关的信息
GetDeviceCaps 获取指定设备的参数设置
EnumMonitors 枚举可用的打印监视器
EnumPorts 枚举一个系统可用的端口
GetPrintProcessorDirectory 判断指定系统中包含了打印机处理器驱动程序及文件的目录
GetPrinterDriverDirectory 判断指定系统中包含了打印机驱动程序的目录是什么
AddPrinter 在系统中添加一台新打印机
DeletePrinter 将指定的打印机标志为从系统中删除
DeletePrinterDriver 从系统删除一个打印机驱动程序
DeletePrinterDriverEx 从系统删除一个打印机驱动程序和相关的文件
FlushPrinter 更新打印机,清楚错误状态的打印机
博主这边再通过help记录下一些有用的参数
DEF_PRIORITY = 1
DI_APPBANDING = 1
DI_ROPS_READ_DESTINATION = 2
DPD_DELETE_ALL_FILES = 4
DPD_DELETE_SPECIFIC_VERSION = 2
DPD_DELETE_UNUSED_FILES = 1
DSPRINT_PENDING = -2147483648
DSPRINT_PUBLISH = 1
DSPRINT_REPUBLISH = 8
DSPRINT_UNPUBLISH = 4
DSPRINT_UPDATE = 2
FORM_BUILTIN = 1
FORM_PRINTER = 2
FORM_USER = 0
JOB_ACCESS_ADMINISTER = 16
JOB_ACCESS_READ = 32
JOB_ALL_ACCESS = 983088
JOB_CONTROL_CANCEL = 3
JOB_CONTROL_DELETE = 5
JOB_CONTROL_LAST_PAGE_EJECTED = 7
JOB_CONTROL_PAUSE = 1
JOB_CONTROL_RESTART = 4
JOB_CONTROL_RESUME = 2
JOB_CONTROL_SENT_TO_PRINTER = 6
JOB_EXECUTE = 131088
JOB_INFO_1 = 1
JOB_POSITION_UNSPECIFIED = 0
JOB_READ = 131104
JOB_STATUS_BLOCKED_DEVQ = 512
JOB_STATUS_COMPLETE = 4096
JOB_STATUS_DELETED = 256
JOB_STATUS_DELETING = 4
JOB_STATUS_ERROR = 2
JOB_STATUS_OFFLINE = 32
JOB_STATUS_PAPEROUT = 64
JOB_STATUS_PAUSED = 1
JOB_STATUS_PRINTED = 128
JOB_STATUS_PRINTING = 16
JOB_STATUS_RESTART = 2048
JOB_STATUS_SPOOLING = 8
JOB_STATUS_USER_INTERVENTION = 1024
JOB_WRITE = 131088
MAX_PRIORITY = 99
MIN_PRIORITY = 1
PORT_STATUS_DOOR_OPEN = 7
PORT_STATUS_NO_TONER = 6
PORT_STATUS_OFFLINE = 1
PORT_STATUS_OUTPUT_BIN_FULL = 4
PORT_STATUS_OUT_OF_MEMORY = 9
PORT_STATUS_PAPER_JAM = 2
PORT_STATUS_PAPER_OUT = 3
PORT_STATUS_PAPER_PROBLEM = 5
PORT_STATUS_POWER_SAVE = 12
PORT_STATUS_TONER_LOW = 10
PORT_STATUS_TYPE_ERROR = 1
PORT_STATUS_TYPE_INFO = 3
PORT_STATUS_TYPE_WARNING = 2
PORT_STATUS_USER_INTERVENTION = 8
PORT_STATUS_WARMING_UP = 11
PORT_TYPE_NET_ATTACHED = 8
PORT_TYPE_READ = 2
PORT_TYPE_REDIRECTED = 4
PORT_TYPE_WRITE = 1
PRINTER_ACCESS_ADMINISTER = 4
PRINTER_ACCESS_USE = 8
PRINTER_ALL_ACCESS = 983052
PRINTER_ATTRIBUTE_DEFAULT = 4
PRINTER_ATTRIBUTE_DIRECT = 2
PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST = 512
PRINTER_ATTRIBUTE_ENABLE_BIDI = 2048
PRINTER_ATTRIBUTE_ENABLE_DEVQ = 128
PRINTER_ATTRIBUTE_FAX = 16384
PRINTER_ATTRIBUTE_HIDDEN = 32
PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS = 256
PRINTER_ATTRIBUTE_LOCAL = 64
PRINTER_ATTRIBUTE_NETWORK = 16
PRINTER_ATTRIBUTE_PUBLISHED = 8192
PRINTER_ATTRIBUTE_QUEUED = 1
PRINTER_ATTRIBUTE_RAW_ONLY = 4096
PRINTER_ATTRIBUTE_SHARED = 8
PRINTER_ATTRIBUTE_TS = 32768
PRINTER_ATTRIBUTE_WORK_OFFLINE = 1024
PRINTER_CONTROL_PAUSE = 1
PRINTER_CONTROL_PURGE = 3
PRINTER_CONTROL_RESUME = 2
PRINTER_CONTROL_SET_STATUS = 4
PRINTER_ENUM_CONNECTIONS = 4
PRINTER_ENUM_CONTAINER = 32768
PRINTER_ENUM_DEFAULT = 1
PRINTER_ENUM_EXPAND = 16384
PRINTER_ENUM_ICON1 = 65536
PRINTER_ENUM_ICON2 = 131072
PRINTER_ENUM_ICON3 = 262144
PRINTER_ENUM_ICON4 = 524288
PRINTER_ENUM_ICON5 = 1048576
PRINTER_ENUM_ICON6 = 2097152
PRINTER_ENUM_ICON7 = 4194304
PRINTER_ENUM_ICON8 = 8388608
PRINTER_ENUM_LOCAL = 2
PRINTER_ENUM_NAME = 8
PRINTER_ENUM_NETWORK = 64
PRINTER_ENUM_REMOTE = 16
PRINTER_ENUM_SHARED = 32
PRINTER_EXECUTE = 131080
PRINTER_INFO_1 = 1
PRINTER_READ = 131080
PRINTER_STATUS_BUSY = 512
PRINTER_STATUS_DOOR_OPEN = 4194304
PRINTER_STATUS_ERROR = 2
PRINTER_STATUS_INITIALIZING = 32768
PRINTER_STATUS_IO_ACTIVE = 256
PRINTER_STATUS_MANUAL_FEED = 32
PRINTER_STATUS_NOT_AVAILABLE = 4096
PRINTER_STATUS_NO_TONER = 262144
PRINTER_STATUS_OFFLINE = 128
PRINTER_STATUS_OUTPUT_BIN_FULL = 2048
PRINTER_STATUS_OUT_OF_MEMORY = 2097152
PRINTER_STATUS_PAGE_PUNT = 524288
PRINTER_STATUS_PAPER_JAM = 8
PRINTER_STATUS_PAPER_OUT = 16
PRINTER_STATUS_PAPER_PROBLEM = 64
PRINTER_STATUS_PAUSED = 1
PRINTER_STATUS_PENDING_DELETION = 4
PRINTER_STATUS_POWER_SAVE = 16777216
PRINTER_STATUS_PRINTING = 1024
PRINTER_STATUS_PROCESSING = 16384
PRINTER_STATUS_SERVER_UNKNOWN = 8388608
PRINTER_STATUS_TONER_LOW = 131072
PRINTER_STATUS_USER_INTERVENTION = 1048576
PRINTER_STATUS_WAITING = 8192
PRINTER_STATUS_WARMING_UP = 65536
PRINTER_WRITE = 131080
SERVER_ACCESS_ADMINISTER = 1
SERVER_ACCESS_ENUMERATE = 2
SERVER_ALL_ACCESS = 983043
SERVER_EXECUTE = 131074
SERVER_READ = 131074
SERVER_WRITE = 131075