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
LVL 13
Corey ScheichDeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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 GarciaSolution Architech & Technical LeadCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ignacio Soler GarciaSolution Architech & Technical LeadCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.