Here is one method to get the status and state of the printer (status includes the items you are looking for as well)
view source
print?
Public Shared Function GetPrinterProperties() As Hashtable
Dim properties As Hashtable = New Hashtable()
Dim searcher As ManagementObjectSearcher = New ManagementObjectSearcher("SELECT * FROM Win32_Printer")
'now loop thorugh all the objects in the searcher
Dim obj As ManagementObject
For Each obj Function searcher.Get() As In
"Other", "Unknown", "Idle", "Printing", "WarmUp", "Stopped Printing", "Offline"
End Function
string() printerState = {"Paused","Error","Pending Deletion","Paper Jam","Paper Out","Manual Feed","Paper Problem", "Offline","IO Active","Busy","Printing",
"Output Bin Full","Not Available","Waiting", "Processing","Initialization","Warming Up","Toner Low","No Toner","Page Punt", "User Intervention Required",
"Out of Memory","Door Open","Server_Unknown","Power Save"
}
'now loop through all the properties
Dim data As PropertyData
For Each data In obj.Properties
'make sure we have the default printer
If CType(obj("Default"),Boolean) Then
Select Case data.Name.ToLower()
Case "printerstate"
properties.Add("State", printerState(Convert.ToInt32(data.Value)))
Exit For
Case "printerstatus"
properties.Add("Status", printerStatus(Convert.ToInt32(data.Value)))
Exit For
End Select
End If
Next
Return properties
Next
End Function
Updated 16-Sep-12 22:39pm
v2