Konlao,
I'm not sure if this work for shared printer, just try this:
------------------
#Define ERROR_INSUFFICIENT_BUFFER 122
#Define PRINTER_STATUS_ERROR 0x02
#Define PRINTER_STATUS_PAPER_JAM 0x08
#Define PRINTER_STATUS_PAPER_OUT 0x10
#Define PRINTER_STATUS_PAPER_PROBLEM 0x40
#Define PRINTER_STATUS_OFFLINE 0x80
#Define PRINTER_STATUS_OUTPUT_BIN_FULL 0x800
#Define PRINTER_STATUS_NOT_AVAILABLE 0x1000
#Define PRINTER_STATUS_NO_TONER 0x40000
#Define PRINTER_STATUS_OUT_OF_MEMORY 0x200000
#Define PRINTER_STATUS_DOOR_OPEN 0x400000
#Define JOB_CONTROL_CANCEL 3
#Define JOB_CONTROL_DELETE 5
Declare Long ClosePrinter in WinSpool.Drv Long hPrinter
Declare Long GetLastError in Kernel32
Declare Long OpenPrinter in WinSpool.Drv ;
String cPrinterName, Long @hPrinter, String pDefault
Declare Long GetJob in WinSpool.Drv ;
Long hPrinter, Long nJobID, Long nLevel, ;
String @cJobInfo, Long nBufSize, Long @nBufNeeded
Local lc_PrinterName, lc_JobInfo, lc_Buffer
Local ln_JobID, ln_Status, ln_Return, ln_hPrinter
lc_PrinterName = GetPrinter()
If !empty(lc_PrinterName)
Store 0 to ln_hPrinter, ln_BufNeeded, ln_Return
If (OpenPrinter(lc_PrinterName, @ln_hPrinter, Null) != 0)
ln_JobID = 1
If (GetJob(ln_hPrinter, 1, 1, 0, 0, @ln_BufNeeded) == 0)
If (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
lc_JobInfo = replicate(chr(0), ln_BufNeeded)
ln_Return = GetJob(ln_hPrinter, 1, 1, @lc_JobInfo, ln_BufNeeded, @ln_BufNeeded)
endif
endif
If (ln_Return > 0)
ln_JobID = DWord2Num(substr(lc_JobInfo, 1, 4))
ln_Status = DWord2Num(substr(lc_JobInfo, (4*7)+1, 4))
? 'Job ID: ', transform(ln_JobID, '@0')
? 'StatusFlag:', transform(ln_Status, '@0')
If (BitAnd(ln_Status, PRINTER_STATUS_ERROR) != 0) or ;
(BitAnd(ln_Status, PRINTER_STATUS_PAPER_JAM) != 0) or ;
(BitAnd(ln_Status, PRINTER_STATUS_PAPER_OUT) != 0) or ;
(BitAnd(ln_Status, PRINTER_STATUS_PAPER_PROBLEM) != 0) or ;
(BitAnd(ln_Status, PRINTER_STATUS_OFFLINE) != 0) or ;
(BitAnd(ln_Status, PRINTER_STATUS_OUTPUT_BIN_FULL) != 0) or ;
(BitAnd(ln_Status, PRINTER_STATUS_NOT_AVAILABLE) != 0) or ;
(BitAnd(ln_Status, PRINTER_STATUS_NO_TONER) != 0) or ;
(BitAnd(ln_Status, PRINTER_STATUS_OUT_OF_MEMORY) != 0) or ;
(BitAnd(ln_Status, PRINTER_STATUS_DOOR_OPEN) != 0)
? ' ***** STATUS ERROR *****'
endif
endif
ClosePrinter(ln_hPrinter)
endif
endif
Clear Dlls
Clear all
Function DWord2Num(tc_Buffer)
Local ln_Result
ln_Result = asc(substr(tc_Buffer, 1,1)) + ;
asc(substr(tc_Buffer, 2,1)) * 256 + ;
asc(substr(tc_Buffer, 3,1)) * 65536 + ;
asc(substr(tc_Buffer, 4,1)) * 16777216
Return ln_Result
EndFunc
------------------
Hope it works
-- AirCon --