Author Message

PostPosted: Visual Basic General, GetDevicePowerState Top

Hello all out there!

My Goal is this:

I want to determine if the star USB strip printer is powered on and in the ready state before i print to it.

So far:

I am using the Printer_Info_2 status (buffer(18)) to get the status. This works fine except for when the printer is powered off. Then the function returns a status of zero which is equivilant to the on line and ready status.

This is a USB printer. I have observed that there is a printer driver detail in the device manager whose name is "Current Power state" . When all is well, it is 'D0' . when the printer is powered down, it is gone or blank. Therefore the potential is there to accomplish my goal.

The information i am seeking to get, is located in the Device Manager/Unversal Serial Bus Controllers/USB Printing Support/Details/Current Power State

There is a microsoft function 'GetDevicePowerState' but it seems to return zero=powered off, all the time.

Any one out there have a solution


Jerry Cicierega

(781) 820 9298


Star Micronics is up against this same dillemma. There answer is to send a 2 byte document to the printer and wait 3 seconds and then query the spooler to see if it is still there.

Visual Basic2  
MSFT Abel Valadez

PostPosted: Visual Basic General, GetDevicePowerState Top

Have you tried using WMI to see what the "PrinterStatus" or "ExtendedPrinterStatus" is The following code will print the status of the available printers:

Sub GetPrinterStatus()
Dim opt As New EnumerationOptions
opt.EnumerateDeep =

mngmtClass As New ManagementClass("win32_printer")

Each o As ManagementObject In mngmtClass.GetInstances(opt)
" Status - " & o.Properties("PrinterStatus").Value.ToString)
Console.WriteLine(" ExtendedStatus - " & o.Properties("ExtendedPrinterStatus").Value.ToString)
End Sub

You can find what the actual return values mean at: url=/library/en-us/wmisdk/wmi/win32_printer.asp

Hope this helps,


PostPosted: Visual Basic General, GetDevicePowerState Top


Thank you for your answer, however these statuses do not report the condition where the power is off on the printer. The problem may lie in the star micronics driver. However windows does indeed know when the power is off. At the time the power is turned off, windows hardware device listings removes the entry that corresponds to that printer.  If i am in the details section of the driver info, the detail named "current power state" goes from D0 to blank. If windows knows the power state then their must be a way to get it into my app.

The WMI may still have the answer but i do not where else to look.

Surely someone out there must know how to interrogate (quickly) the device driver in question and enumerate the details to get the "Current Power State" string.


I throw back the challenge.


Jerry C