• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 259
  • Last Modified:

Watching a printer for events

Is there a way to watch a printer for events I would like to retreive the file name that was printed and attach it to an e-mail with a short message saying what to do with the print.

Corey
0
Corey Scheich
Asked:
Corey Scheich
  • 2
  • 2
2 Solutions
 
iboutchkineCommented:
I don't think that you can get such info about file is being printed from the printer. (Also you can get it from your code).
You can get info about printer status

Private Enum PrinterStatus
        PrinterIdle = 3
        PrinterPrinting = 4
        PrinterWarmingUp = 5
    End Enum

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim strPrintServer As String
        strPrintServer = "localhost"
        Dim WMIObject As String, PrinterSet As Object, Printer As Object
        WMIObject = "winmgmts://" & strPrintServer
        PrinterSet = GetObject(WMIObject).InstancesOf("win32_Printer")
        For Each Printer In PrinterSet
            MsgBox(Printer.Name & ":  " & PrinterStatusToString(Printer.PrinterStatus))
        Next Printer
    End Sub


    Private Function PrinterStatusToString(ByVal ps As PrinterStatus) As String
        Dim s As String
        Select Case ps
            Case PrinterStatus.PrinterIdle
                s = "waiting (idle)"
            Case PrinterStatus.PrinterPrinting
                s = "printing"
            Case PrinterStatus.PrinterWarmingUp
                s = "warming up"
            Case Else  
                s = "unknown state"
        End Select
        PrinterStatusToString = s
    End Function
0
 
Ignacio Soler GarciaCommented:
Look here to take an overview of what happens with this:

http://www.microsoft.com/resources/documentation/msa/edc/all/solution/en-us/pak/sog/edcops09.mspx

Then you can check the performance monitor to look for the events at the Spool Queue (or whatever is its name on your system, im Spanish). There you can find the most useful events.

Check the vb help about the PerformanceCounter Class to know more about it.

See you.

SoMoS
0
 
Ignacio Soler GarciaCommented:
What do you think about the solutions presented here Corey2???

SoMoS
0
 
Corey ScheichDeveloperAuthor Commented:
They both look good though I haven't had a chance to really check into it to make a decision on who deserves what point values.  Hopefully I will get a chance soon here.  Please bear with me.

Corey
0
 
Corey ScheichDeveloperAuthor Commented:
Unfortunately I haven't been able to explore the possibilities here.  So I am unable to pick the answer which would most fit my situation I am going to evenly split the points because both solutions look good.

Thank you

Corey2
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now