Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to get the count of printed pages from any application

Posted on 2002-03-09
3
Medium Priority
?
226 Views
Last Modified: 2010-04-05
Hi All,

How can i get the printed pages from any Application on my computer.

i want to write a small Application to monitoring how many pages already printed from my computer , and the printer is not local installed.

Hope for a good tips

Thanks Willy
0
Comment
Question by:wchandra
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 9

Accepted Solution

by:
ginsonic earned 600 total points
ID: 6852493
Try this :

unit Unit1;


interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,StdCtrls,WinSpool,Printers ;

type
TForm1 = class(TForm)
    Button1: TButton;
    ListBox1: TListBox;
    procedure Button1Click(Sender: TObject);
private
  { Private declarations }
public
  { Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);

 const
   MaxJobs = 1024;
 type
   TArrayofJobs = array[1..1024] of TJobInfo2;
 var
   NumJobs : integer;
   pcbNeed,pcReturned:DWord;
   i : integer;
   Device : array[0..255] of char;
   Driver : array[0..255] of char;
   Port   : array[0..255] of char;
   hPrinter: THandle;
   hDeviceMode: THandle;
   Buffer: Pointer;
   TmpWinDir : array[0..255] of Char;
   Windir : string;

 begin
   if GetWindowsDirectory(TmpWinDir, sizeof(TmpWinDir)) <> 0 then
     Windir := Strpas(TmpWinDir) + '\SPOOL\PRINTERS\'
   else
     Windir := 'C:\WINDOWS\SPOOL\PRINTERS\';

   Printer.GetPrinter(Device, Driver, Port, hDeviceMode);
   if not WinSpool.OpenPrinter(@Device, hPrinter, nil) then exit;

   ListBox1.items.clear;

   GetPrinter(hPrinter, 2, nil,0,@pcbNeed);
   GetMem(Buffer, pcbNeed);

  if EnumJobs(hPrinter, 0, NumJobs, 2, Buffer, pcbNeed, pcbNeed,pcReturned) then
     begin
       for i := 1 to pcReturned do
         begin
           ListBox1.items.add('TotalPages='+Inttostr(TarrayofJobs(buffer^)[i].TotalPages));
           ListBox1.items.add('PagesPrinted='+Inttostr(TarrayofJobs(buffer^)[i].PagesPrinted));

           SetJob(hPrinter, TArrayofJobs(buffer^)[i].JobId, 0, nil,JOB_CONTROL_CANCEL);
         end;
     end;
   FreeMem(Buffer, pcbNeed);

   WinSpool.ClosePrinter(hPrinter);
 end;

end.
0
 

Expert Comment

by:CleanupPing
ID: 9343289
wchandra:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 7

Expert Comment

by:knightmad
ID: 9470508
Wow, Its been a long time since this comment have been visited!

wchandra,
No comment has been added lately (19 days), so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:

RECOMMENDATION: Award points to ginsonic http:#6852493

-- Please DO NOT accept this comment as an answer ! --

Thanks,

knightmad
EE Cleanup Volunteer

Remember you (all) can object this recommendation if you disagree, just leave a post here explaining why are you objecting and what should be done instead.
Within 7 days probably this thread will be closed, so, hurry up! : )
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question