SETHA SITE INFORMATION

  • Increase font size
  • Default font size
  • Decrease font size

How to Check All Printers Status (Idle, Printing, Unknown) in Visual Basic .Net?

E-mail Print PDF

This article shows you the way to write Visual Basic .Net code to check all local existing printers status whether some printers are printing and some are not. The VB code below uses ListView control to display printers status.

Private Sub CheckPrinter()
        Dim Printers As Object
        Dim Printer As Object
        Dim WMIObj As String
        Dim lItem As ListViewItem

        WMIObj = "winmgmts://localhost"
        Printers = GetObject(WMIObj).InstancesOf("win32_Printer")
        'clear list
        Me.lvwPrinter.Items.Clear()
        For Each Printer In Printers
            lItem = Me.lvwPrinter.Items.Add(Printer.name)
            Select Case Printer.PrinterStatus
                Case 3
                    lItem.SubItems.Add("Idle")
                Case 4
                    lItem.SubItems.Add("Printing")
                Case Else
                    lItem.SubItems.Add("Unknown")
            End Select
        Next
End Sub
Download Source Code