Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How many pages printed
Message
 
À
01/08/2006 12:10:56
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP1
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01141921
Message ID:
01142145
Vues:
12
Thanks!!!

I'll toy with it and see what I can find out


BDH


>> I’d like to write a program that will monitor the printing
>> activities and will give the total pages printed on a PC,
>> We are using a printer server with lots of printers installed.
>
>This could be done using WMI events from VFP: this sample event query listens for print jobs being created.
>(Unfortunately it won't get the page count "if the print job does not contain page-delimiting information.")
>
>
>
>*** WMI Event sample -
>
>* When a new printjob is started, echo the originating pc and page count
>* RELEASE oEventCatcher in the command window to stop.
>
>public oEventCatcher
>
>oEventCatcher = createobject("eventcatcher")
>
>cQuery = [select * from __InstanceCreationEvent within 0.1 where TargetInstance ISA 'Win32_PrintJob']
>oEventCatcher.CatchEvents(cQuery)
>
>return
>
>** Event catching class
>
>define class eventcatcher as relation
>
>	oSink = .null.
>	oWbemSink = .null.
>	oWMI = .null.
>
>	procedure init
>
>		this.oWMI = getobject("winmgmts:")
>		* Create the sink objects and bind them
>		this.oWbemSink = createobject("wbemscripting.swbemsink")
>		this.oSink = createobject("vfpsink")
>		eventhandler(this.oWbemSink, this.oSink)
>
>	endproc
>
>	procedure destroy
>
>		if vartype(this.oWbemSink) = "O"
>			this.oWbemSink.Cancel()
>		endif
>
>	endproc
>
>	procedure CatchEvents
>		lparameters cQuery
>		* Send the WMI sink not the VFP one.
>		this.oWMI.ExecNotificationQueryAsync(this.oWbemSink, cQuery)
>	endproc
>
>enddefine
>
>** The sink class is easier to manage when decoupled from the eventcatcher class
>
>define class vfpsink as relation
>
>	implements ISWbemSinkEvents in "WbemScripting.SWbemSink"
>
>	procedure ISWbemSinkEvents_OnObjectReady(oObject, oAsyncContext)
>		? "Originating PC: " + oObject.TargetInstance.HostPrintQueue
>		? "Pages: " + transform(oObject.TargetInstance.TotalPages)
>	endproc
>
>	procedure ISWbemSinkEvents_OnCompleted(nResult, oErrorObject, oAsyncContext)
>	procedure ISWbemSinkEvents_OnProgress(nUpperBound, nCurrent, cMessage, oAsyncContext)
>	procedure ISWbemSinkEvents_OnObjectPut(oObjectPath, oAsyncContext)
>
>enddefine
>
B.D.H.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform