Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How Many Pages Printed & Scanned

Status
Not open for further replies.

gazal

Programmer
Apr 30, 2003
212
OM
Hi Friends

I dont know this question may sound weird but i cant help it coz its required by my client.

I am using Windows 98 as my operating system.

Is it possible, using VB 6.0, can we findout that how many Pages were printed by a printer on a given date, or even if it shows total number of pages printed by the printer as on date will also do and same is the requirement for the scanner also.

Please note right now i m dealing with Canon BJC 1000 printer and PRIMAX 1200 dpi Scanner. But i would like that it should work with any brand.

So is it possible, does windows store this information somewhere in registry or some other place???

Thanks in advance

Gazal

 
Do you mean total number of pages printed (by any application) or total number printed by your application. If it is your application then you could just log each print but if its all applications I suspect it will be very difficult...
 
nope i mean total number of printouts by any application, it can be MS WORD, EXCEL, POwer Point etc....

 
hi thanks for the link

it has been of great help, has got me started up, but still not serving the purpose. my main intention is to get the no. of printouts taken out. And let me mention it again it can be through any application. Ok here i have got some idea may be it can work.

We all know the machine to which the printer is attached has got a printer port, to which the Data Cable of printer is connected. So for the print job to get spooled it has to go thorugh the printer port. So its obvious that when ever a print job is fired from any application it has to route through this printer port, and must be containing information about no. of pages, data type etc... (Which normally all printer softwares show)So by using MSCOMM control can we read the data sent to the printer port by any application. I know that mscomm can read from Com Port. So any suggestions or ideas

thanks

gazal


 
Using the API's I have suggested make a form with a timer (Timer1) and a label (label1).

Add this to your form:

Code:
Private Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" (ByVal pPrinterName As String, phPrinter As Long, pDefault As Any) As Long
Private Declare Function ClosePrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long
Private Declare Function EnumJobs Lib "winspool.drv" Alias "EnumJobsA" (ByVal hPrinter As Long, ByVal FirstJob As Long, ByVal NoJobs As Long, ByVal Level As Long, pJob As Any, ByVal cdBuf As Long, pcbNeeded As Long, pcReturned As Long) As Long
Dim intPrint

Private Sub Timer1_Timer()
   'KPD-Team 2001
   'URL: [URL unfurl="true"]http://www.allapi.net/[/URL]
   'E-Mail: KPDTeam@Allapi.net
   Dim hPrinter As Long, lNeeded As Long, lReturned As Long
   Dim lJobCount As Long
   OpenPrinter Printer.DeviceName, hPrinter, ByVal 0&
   EnumJobs hPrinter, 0, 99, 1, ByVal 0&, 0, lNeeded, lReturned
   If lNeeded > 0 Then
       ReDim byteJobsBuffer(lNeeded - 1) As Byte
       EnumJobs hPrinter, 0, 99, 1, byteJobsBuffer(0), lNeeded, lNeeded, lReturned
       If lReturned > 0 Then
           lJobCount = lReturned
       Else
           lJobCount = 0
       End If
   Else
       lJobCount = 0
   End If
   ClosePrinter hPrinter
   intPrint = intPrint + lJobCount
   Label1.Caption = "Printed Jobs: " & intPrint
End Sub
 
gazal,

I am not clear, are you looking to capture the number of print jobs submitted to the printer queue or more information ( number of copies & number of pages)?

if you are looking for just the number of jobs submitted then ca8msm covers it,

If not you need to read up on printer APIs, especially the GetJobInfo calls and JOB_INFO structures.

There is (allegedly) a bug with the MS office series of apps, that means they do not set the DEVMODE structure (held in the JOB_INFO2 Structure) correctly wrt the number of copies. Does anyone else know of this and a workround?

Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
>how many Pages were printed by a printer on a given date

Apologies - I've just re-read the original post and it was pages you asked for and not jobs. If you can get away with using the number of jobs then fine, otherwise as mattknight says you will need to delve further than the code provided.
 
U R RIGHT matt

i m looking for no. of copies only, thought no of jobs also can help a bit, but will not give me the exact picture. but if i can get the no. of copies then it would be of great help

hey guys what about reading the printer port !!! no ideas???


gazal
 
Reading the printer port would be kind of pointless. You would have to process a lot of data and sit and wait while you increase a counter after every page. But, then again, that might be the only way to do what you'r trying to do.
~ TripleFault !)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top