Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub CheckPrinter(ByVal printerName As String, ByVal labelName As Label)
- Dim query As String = $"SELECT * FROM Win32_Printer WHERE Name LIKE '%{printerName}%'"
- Dim searcher As New ManagementObjectSearcher(query)
- Dim coll As ManagementObjectCollection = searcher.Get()
- For Each printer As ManagementObject In coll
- Dim printerStatus As String = printer("PrinterStatus").ToString()
- Dim paperStatus As String = printer("PrinterState").ToString()
- If printerStatus = "3" Then
- If paperStatus = "5" Then
- labelName.Text = "ONLINE - OUT OF PAPER"
- labelName.ForeColor = Color.Yellow
- Else
- labelName.Text = "ONLINE"
- labelName.ForeColor = Color.Green
- End If
- Else
- labelName.Text = "OFFLINE"
- labelName.ForeColor = Color.Red
- End If
- Next
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement