Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can you find out if a printer is offline/online - API maybe??

Status
Not open for further replies.

Tarmac

Programmer
Sep 24, 1998
3
US
Does anyone know of an API call or whatever to find out if a printer is online or offline??
 
There is an API Function called 'GetPrinter' which will return PRINTER_INFO_x (the x can be 1-5). Each PRINTER_INFO structure is designed to give various levels of information. I'm not sure which contains the 'status' of online/offline but I do know that it is in one of them. Do a search on both GetPrinter and PRINTER_INFO_ to find out exactly how to use them. The declaration for 'GetPrinter' in Visual Basic is:<br>
<br>
Declare Function GetPrinter& Lib "spoolss.dll" Alias "GetPrinterA" (ByVal hPrinter As Long, ByVal Level As Long, pPrinter As Byte, ByVal cbBuf As Long, pcbNeeded As Long)<br>
<br>
where<br>
hPrinter is a handle to an open printer<br>
Level is the 'x' for the PRINTER_INFO_x<br>
pPrinter is buffer to load with info<br>
cbBuf will be the size of the buffer<br>
pcbNeeded is how many bytes will be needed for the info.<br>
<br>
HTH, Spaz
 
This should work.<br>
{newline}<br>
Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" (ByVal pPrinterName As String, phPrinter As Long, pDefault As PRINTER_DEFAULTS) As Long.<br>
<br>
{newline}<br>
Type PRINTER_DEFAULTS<br>
{newline}pDatatype As String<br>
{mewline}pDevMode As Long<br>
{newline}DesiredAccess As Long<br>
{newline}<br>
End Type<br>
<br>

 
Thats brill folks - thanks a mill! :~)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top