Last revised: 16-01-2009.
This simple Visual Basic 6.0 example should give you an idea about how simple it is to create your own monitoring applications.
Prerequisites:
Paste this code into the declarations section of the form:
Option Explicit
'
' Define the monitor object using the WithEvents keyword
' to be able to receive events.
Private WithEvents oMyMonitor As
QueueMonDLL.Application
Private Sub Command1_Click()
'
' The StartMonitoring function will NOT return until
' monitoring has ended. Hence, the code will NOT execute
' any further. However, it will NOT block your application
' UI, so you can use Command2 to call StopMonitoring.
oMyMonitor.StartMonitoring
End Sub
Private Sub Command2_Click()
oMyMonitor.StopMonitoring
End Sub
Private Sub Form_Load()
Command1.Caption = "Start"
Command2.Caption = "Stop"
Set oMyMonitor =
New QueueMonDLL.Application
oMyMonitor.RunMode = enrmStandardClient
End Sub
Private Sub Form_Unload(Cancel As
Integer)
Command2_Click
Set oMyMonitor = Nothing
End Sub
Private Sub oMyMonitor_OnJobDone(ByVal
oJob As QueueMonDLL.PrinterJob)
List1.AddItem oJob.Document & " printed for " & oJob.UserName
End Sub
Private Sub oMyMonitor_OnJobStart(ByVal
oJob As QueueMonDLL.PrinterJob)
List1.AddItem oJob.Document & " started for " & oJob.UserName
End Sub
Private Sub oMyMonitor_OnMonitoringStarted()
List1.AddItem "Monitoring has started."
End Sub
Private Sub oMyMonitor_OnMonitoringStopped()
List1.AddItem "Monitoring has stopped."
End Sub
Run the project and press the Start button. Then print a test document to a valid Publi PDF printer instance and view the comments written to the list box.
This code represent a complete, but very simple client application that monitor any pre-configured attended queues (i.e. queues that already are configured correctly via the configuration file).
Download the sample project (requires a licensed version of Publi PDF to run).