标签:
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