码迷,mamicode.com
首页 > 其他好文 > 详细

监控打印机

时间:2016-06-29 19:01:16      阅读:272      评论:0      收藏:0      [点我收藏+]

标签:

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

监控打印机

标签:

原文地址:http://www.cnblogs.com/findumars/p/5627596.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!