#include<Winspool.h>
DWORD GetPrinterStatus( char* szPrnName )
{
HANDLE hHandle = 0; // Handle of the printer
DWORD dwStatus = 0; // Printer status we should receive// Few values for example:// 0x00000000 - ready// 0x00000001 - paused// 0x00000002 - error// 0x00000200 - busy// 0x00000400 - printing// for more info please see MSDN
DWORD dwSize = 0; // Size of memory we should// allocate for PRINTER_INFO_2
PRINTER_INFO_2* pPrnInfo2 = 0; // Structure specifies detailed// printer information
DEVMODE DevMode = {0}; // Structure contains information// about the device initialization// and environment of a printer
PRINTER_DEFAULTS PrnDef = { 0, &DevMode, PRINTER_ACCESS_USE };
// Open printer with name szPrnNameif( !OpenPrinter( szPrnName, &hHandle, &PrnDef ) )
return0; // Error// How many memory should be allocated for printer data?
GetPrinter( hHandle, 2, 0, 0, &dwSize );
if( !dwSize )
return0; // Error// Allocate memory
pPrnInfo2 = (PRINTER_INFO_2*)malloc( dwSize );
// Receive printer detailsif(!GetPrinter( hHandle, 2, (LPBYTE)pPrnInfo2, dwSize, &dwSize ))
return0; // Error
dwStatus = pPrnInfo2->Status;
// Free allocated memory
free( pPrnInfo2 );
// Close printer
ClosePrinter( hHandle );
return dwStatus;
}
«Universal Document Converter is a instrument that allows me to do my CRM consultant work much faster. It converts Documents for my clients, in various Formats such as PDF, docx, and even image diagrams in JPEG, BMP, PCX, PNG, with the best conversion quality!»