1

So I've tried various things so far. I'm not quite sure whether I should be looking for the 'printer to be offline' or for the queue to be offline.

Using the below I am able to return the default queue and all of the various properties of the queue. But when I unplug the usb printer (or set it to 'use offline' ) I never see the .IsOffline property change.

  Dim myDefaultQueue As PrintQueue = Nothing

    Dim localPrintServer As New LocalPrintServer()
    ' Retrieving collection of local printer on user machine
    myDefaultQueue = localPrintServer.GetDefaultPrintQueue

    myDefaultQueue.Refresh()

    If myDefaultQueue.IsOffline Then

        MsgBox("Your printer is offline")

    End If

The example is what I've been working off of

https://msdn.microsoft.com/library/aa970685(v=vs.100).aspx

mellerbeck
  • 199
  • 2
  • 14

1 Answers1

0

This appears to be the best way to find if a printer is 'offline' or not

How to get Printer Info in .NET?

string printerName = "YourPrinterName";
string query = string.Format("SELECT * from Win32_Printer WHERE Name LIKE '% {0}'", printerName);
ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
ManagementObjectCollection coll = searcher.Get();

foreach (ManagementObject printer in coll)
{
foreach (PropertyData property in printer.Properties)
{
    Console.WriteLine(string.Format("{0}: {1}", property.Name, property.Value));
}

}

Community
  • 1
  • 1
mellerbeck
  • 199
  • 2
  • 14