Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How To Monitor Printer Activities in Win98?

Posted on 2003-11-19
11
Medium Priority
?
655 Views
Last Modified: 2012-05-04
I am using VB6 and Win98.

I need to write a program running in the background that would allow only 5 pages to be printed, whether from MS Word, Excel, Webbrowser, etc.  After the 5th page printed, no printing would be allowed.

There is only 1 printer connected to the computer and no network connections.

Please help!  I can increase the points if this turns out to be a tough one.

0
Comment
Question by:limva
[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
  • 5
  • 5
11 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 9785196
See http://www.merrioncomputing.com/Programming/WatchPrinter.htm It can be helpful for you
--> complete source code included
maybe this can help:
-->http://www.karenware.com/powertools/ptprnlog.asp

0
 
LVL 2

Expert Comment

by:Merrion
ID: 9785714
The former link is only for Windows NT, 2000 and XP systems - for Windows 9x you need to subclass your application main window and look out for the WM_SPOOLERSTATUS window message.  Note that printer monitoring from Windows 9x is a lot less accurate and reliable than is the case in NT and derived systems.
0
 
LVL 2

Expert Comment

by:Merrion
ID: 9785715
The former link is only for Windows NT, 2000 and XP systems - for Windows 9x you need to subclass your application main window and look out for the WM_SPOOLERSTATUS window message.  Note that printer monitoring from Windows 9x is a lot less accurate and reliable than is the case in NT and derived systems.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:limva
ID: 9795311
Thanks Merrion.  Sorry I couldn't get back to you earlier because the internet wasn't working for me this morning.  I'll take a look at your suggestions and let you know tomorrow.

0
 

Author Comment

by:limva
ID: 9799270
Hi Merrion.

This might be too much to ask.  Would you be able to give me the API codes or at least point me to examples for doing the following:?

1. Set a hook to raise an event when there is an attempt to print.
2. Determine the number of pages user is attempting to print.
3. Programmatically cancel the printing job if program determines the print pages have exceeded the limit.

There is just 1 printer and 1 computer, both local.

If the solution deserves more points please let me know.

Thanks!
0
 
LVL 2

Expert Comment

by:Merrion
ID: 9809146
I can't reliably do #1 as I don't have access to a Win98 machine to test it - however it is the general "subclassing a window in VB" example looking for WM_SPOOLERSTATUS

Public Const WM_SPOOLERSTATUS = &H2A


For 2 use the EnumJobs and GetJob APIs as per this article:
http://www.merrioncomputing.com/Programming/PrintJob.htm

For 3 use the SetJob API call with the command as per this code:
http://www.merrioncomputing.com/EventVB/EventVB~ApiPrintJob_CODE.html
'---
lret = SetJob(mhPrinter, mJobId, 0, 0, JOB_CONTROL_CANCEL)

0
 

Author Comment

by:limva
ID: 9840272
Hi Merrion.  I haven't forgotten this question.  I will try to follow your suggestions above as best as I can over the weekend and let you know.

Thanks!
0
 

Author Comment

by:limva
ID: 9938138
Hello Merrion.  Sorry for the gap in time.  I was working on another project.

Apparently Windows 98 does not report print spool info accurately.  I tried opening the spool file (*.SPL) in the C:\Windows\spool\Printers\ folder and parse it to count the pages to be printed and was successful, but it turned out that the SPL file format is different for each printer, depending on its driver.  So I cannot use that.

What I have concluded is just to change the OS from Win98 to either Win NT or Win2000.  My question is, Merrion, can I use my current version of VB6 on Win NT or Win2000?  Or is there a different version of VB6 for NT?


Thanks!
0
 
LVL 2

Accepted Solution

by:
Merrion earned 800 total points
ID: 9938339
The spooler subsystem is entirely different between (a)windows 95/98/Me and (b)NT4/XP/2000

In case (a) whenever a print job is spooled a WM_SPOOLERSTATUS message is broadcast to top level windows and they can intercept it.  Also a seperate ~.tmp file is created for every page of a print job.  This is always in the printer specific raw format

In case (b) the printer can be monitored by setting a FindFirstPrinterChangeNotification handle and every print job has a .spl file and a .shd file.  You can opt to store the spool files in RAW format or as EMF formatted file, in which case the .spl file is a collection of EMF records, one for each page.

Printer logging is notoriously unreliable in case a which is why most commercial offerings are for (b) only.
0
 

Author Comment

by:limva
ID: 9943125
The answer is to go NT or Windows 2000.

Thanks Merrion!
0
 
LVL 2

Expert Comment

by:Merrion
ID: 9943329
Note that only the print server need be NT/2000/XP for all that stuff to apply....and (IMHO) it should be anyway from a security point of view.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

636 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