监控打印机
2016-06-29 17:14
393 查看
uses Winapi.WinSpool;
procedure TForm1.Button1Click(Sender: TObject);
var
pi2: PRINTER_INFO_2;
hPrinter: THandle;
Jobs: array [0 .. 1000] of TJobInfo2;
BytesNeeded, NumJobs: Dword;
begin
pi2.pPrinterName := 'Microsoft XPS Document Writer';
if OpenPrinter(pi2.pPrinterName, hPrinter, 0) then
begin
while true do
begin
WaitForPrinterChange(hPrinter, PRINTER_CHANGE_ADD_JOB);
if EnumJobs(hPrinter, 0, 1000, 2, @Jobs, SizeOf(Jobs), BytesNeeded,
NumJobs) then
begin
if NumJobs <> 0 then
begin
with Jobs[NumJobs - 1] do
showmessage(StrPas(pUserName) + StrPas(pMachineName) +
StrPas(pDocument));
end;
end;
end;
end;
end;
可监控的打印机状态参数记录:
_JOB_INFO_2W = record
JobId: DWORD;
pPrinterName: LPWSTR;
pMachineName: LPWSTR;
pUserName: LPWSTR;
pDocument: LPWSTR;
pNotifyName: LPWSTR;
pDatatype: LPWSTR;
pPrintProcessor: LPWSTR;
pParameters: LPWSTR;
pDriverName: LPWSTR;
pDevMode: PDeviceModeW;
pStatus: LPWSTR;
pSecurityDescriptor: PSECURITY_DESCRIPTOR;
Status: DWORD;
Priority: DWORD;
Position: DWORD;
StartTime: DWORD;
UntilTime: DWORD;
TotalPages: DWORD;
Size: DWORD;
Submitted: TSystemTime; { Time the job was spooled }
Time: DWORD; { How many seconds the job has been printing }
PagesPrinted: DWORD;
end;
http://www.cnblogs.com/hnxxcxg/p/4447758.html
procedure TForm1.Button1Click(Sender: TObject);
var
pi2: PRINTER_INFO_2;
hPrinter: THandle;
Jobs: array [0 .. 1000] of TJobInfo2;
BytesNeeded, NumJobs: Dword;
begin
pi2.pPrinterName := 'Microsoft XPS Document Writer';
if OpenPrinter(pi2.pPrinterName, hPrinter, 0) then
begin
while true do
begin
WaitForPrinterChange(hPrinter, PRINTER_CHANGE_ADD_JOB);
if EnumJobs(hPrinter, 0, 1000, 2, @Jobs, SizeOf(Jobs), BytesNeeded,
NumJobs) then
begin
if NumJobs <> 0 then
begin
with Jobs[NumJobs - 1] do
showmessage(StrPas(pUserName) + StrPas(pMachineName) +
StrPas(pDocument));
end;
end;
end;
end;
end;
可监控的打印机状态参数记录:
_JOB_INFO_2W = record
JobId: DWORD;
pPrinterName: LPWSTR;
pMachineName: LPWSTR;
pUserName: LPWSTR;
pDocument: LPWSTR;
pNotifyName: LPWSTR;
pDatatype: LPWSTR;
pPrintProcessor: LPWSTR;
pParameters: LPWSTR;
pDriverName: LPWSTR;
pDevMode: PDeviceModeW;
pStatus: LPWSTR;
pSecurityDescriptor: PSECURITY_DESCRIPTOR;
Status: DWORD;
Priority: DWORD;
Position: DWORD;
StartTime: DWORD;
UntilTime: DWORD;
TotalPages: DWORD;
Size: DWORD;
Submitted: TSystemTime; { Time the job was spooled }
Time: DWORD; { How many seconds the job has been printing }
PagesPrinted: DWORD;
end;
http://www.cnblogs.com/hnxxcxg/p/4447758.html
相关文章推荐
- Hadoop中HDFS的存储机制
- springmvc整合mybatis错误:java.lang.AbstractMethodError,sqlSessionFactoryBeanName造成tomcat启动错误
- OpenCV 3.0中IplImage* 转cv::Mat
- PXE实现批量安装部署(win与linux系统)
- linux socket 缓冲区默认大小
- centos7上通过手工方式和shell脚本方式安装jdk
- 搭建samba 实现虚拟机与本机文件共享
- as4 通过yum自动升级实现
- 各种解压缩 linux .tar .gz .bz2 .bz .zip
- 19.Shell文件包含
- linux设备树的解释 - DTC编译器
- Linux下如何执行Shell脚本
- 嵌入式 如何定位死循环或高CPU使用率(linux)
- 每天一个linux命令(40):ifconfig命令
- Linux 下查看线程信息
- linux命令行编辑快捷键
- Shell good example
- shell-百度百科
- Linux常用命令--dos2unix
- 使用EasyBCD完美实现Windows7与Linux双系统