getting printer status 
Author Message
 getting printer status

Hi,

is there any way  to see if a given printer is working ok? With this i mean,
is it out of paper, paper jam ... etc.
But basicly if I could tell printer OK / printer NOT OK that would be great
...

Thanks,
Kristof



Mon, 10 Oct 2005 20:47:11 GMT  
 getting printer status
Hello,


Quote:
> is there any way  to see if a given printer is working
> ok? With this i mean, is it out of paper, paper jam ... etc.
> But basicly if I could tell printer OK / printer NOT OK
> that would be great

Quick and dirty:

\\\
Private Enum PrinterStatus
    PrinterIdle = 3
    PrinterPrinting = 4
    PrinterWarmingUp = 5
    ' For more states see WMI docs.
End Enum

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   ' Vielleicht gibt es noch weitere F?lle...
            s = "unknown state"
    End Select
    PrinterStatusToString = s
End Function

Private Sub Form1_Load( _
    ByVal sender As System.Object, _
    ByVal e As System.EventArgs _
) Handles MyBase.Load
    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
///

Documentation of WMI classes:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmis...

Regards,
Herfried K. Wagner



Mon, 10 Oct 2005 21:58:07 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Getting Printer Status

2. GETTING PRINTER STATUS

3. Getting Printer Status

4. Getting printer status from 95

5. Getting Printer Status

6. Getting printer status with VB 5.0 (SP3)

7. Getting Printer Status

8. Getting status of Printer

9. Getting network printer status

10. ?printer status of LAN printer

11. Printer - Printer Status

12. Q: Forcing Printer Paper bins / Getting List Per Printer

 

 
Powered by phpBB® Forum Software