Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to get a list of current print jobs Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
15-Aug-03
Category
Reporting /Printing
Language
Delphi 3.x
Views
130
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

Is there any way in Delphi to check for the printer queue or if a printer has 
received and printed a document correctly?

Answer:

No there is not any bullet-proof way of determining that a document has been 
printed correctly. Nevertheless here is a routine to collect all the running jobs 
of a printer. Keep in mind that the only way to retrieve this information is by 
pooling it from the spooler in standard intervals.

1   { ... }
2   type
3     PJobInfoArray = ^TJobInfoArray;
4     TJobInfoArray = array[0..0] of winspool.JOB_INFO_2;
5   
6   procedure GetJobs(APrinter: string);
7   var
8     Size, Needed, Returned, CNT: Cardinal;
9     Res: LongBool;
10    Prn: Cardinal;
11    PrnName: Pchar;
12    vJobs: PJobInfoArray;
13  begin
14    ReAllocMem(PrnName, Length(aPrinter) + 2);
15    CopyMemory(PrnName, @aPrinter[1], Length(aPrinter));
16    Res := OpenPrinter(PrnName, Prn, nil);
17    ReAllocMem(PrnName, 0);
18    if LongInt(Res) = 0 then
19      RaiseLastOSError;
20    Size := 0;
21    Res := WinSpool.EnumJobs(Prn, 0, 999, 2, VJobs, 0, Needed, Returned);
22    Size := Needed;
23    reAllocMem(VJobs, Size);
24    Res := EnumJobs(Prn, 0, 999, 2, vJobs, Size, Needed, Returned);
25    if LongInt(Res) > 0 then
26    begin
27      reAllocMem(vJobs, 0);
28      ClosePrinter(Prn);
29      RaiseLastOSError;
30    end;
31    ReAllocMem(VJobs, 0);
32    ClosePRinter(Prn);
33  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC