Here is a window which I think will work, I am still testing. The case statement is meant to convert the value constants to a string.
forward
global type w_main from window
end type
type cb_process from commandbutton within w_main
end type
type cb_cancel from commandbutton within w_main
end type
type printer_info_6 from structure within w_main
end type
end forward
type printer_info_6 from structure
unsignedlong dwstatus
unsignedlong reserved
end type
global type w_main from window
integer width = 2098
integer height = 1460
boolean titlebar = true
string title = "Printer Status"
boolean controlmenu = true
long backcolor = 67108864
string icon = "AppIcon!"
boolean center = true
cb_process cb_process
cb_cancel cb_cancel
end type
global w_main w_main
type prototypes
Function boolean GetDefaultPrinter ( &
Ref string pszBuffer, &
Ref ulong pcchBuffer ) &
Library "winspool.drv" Alias For "GetDefaultPrinterW"
Function boolean OpenPrinter ( &
string pPrinterName, &
Ref long phPrinter, &
ulong pDefault ) &
Library "winspool.drv" Alias For "OpenPrinterW"
Function boolean ClosePrinter ( &
long hPrinter ) &
Library "winspool.drv"
Function boolean GetPrinter ( &
long hPrinter, &
ulong Level, &
Ref structure pPrinter, &
ulong cbBuf, &
Ref ulong pcbNeeded ) &
Library "winspool.drv" Alias For "GetPrinterW"
end prototypes
type variables
Constant ULong PRINTER_STATUS_BUSY = 512 // 0x00000200
Constant ULong PRINTER_STATUS_DOOR_OPEN = 4194304 // 0x00400000
Constant ULong PRINTER_STATUS_ERROR = 2 // 0x00000002
Constant ULong PRINTER_STATUS_INITIALIZING = 32768 // 0x00008000
Constant ULong PRINTER_STATUS_IO_ACTIVE = 256 // 0x00000100
Constant ULong PRINTER_STATUS_MANUAL_FEED = 32 // 0x00000020
Constant ULong PRINTER_STATUS_NO_TONER = 262144 // 0x00040000
Constant ULong PRINTER_STATUS_NOT_AVAILABLE = 4096 // 0x00001000
Constant ULong PRINTER_STATUS_OFFLINE = 132 // 0x00000080
Constant ULong PRINTER_STATUS_OUT_OF_MEMORY = 2097152 // 0x00200000
Constant ULong PRINTER_STATUS_OUTPUT_BIN_FULL = 2048 // 0x00000800
Constant ULong PRINTER_STATUS_PAGE_PUNT = 524288 // 0x00080000
Constant ULong PRINTER_STATUS_PAPER_JAM = 8 // 0x00000008
Constant ULong PRINTER_STATUS_PAPER_OUT = 16 // 0x00000010
Constant ULong PRINTER_STATUS_PAPER_PROBLEM = 64 // 0x00000040
Constant ULong PRINTER_STATUS_PAUSED = 1 // 0x00000001
Constant ULong PRINTER_STATUS_PENDING_DELETION = 4 // 0x00000004
Constant ULong PRINTER_STATUS_POWER_SAVE = 16777216 // 0x01000000
Constant ULong PRINTER_STATUS_PRINTING = 1024 // 0x00000400
Constant ULong PRINTER_STATUS_PROCESSING = 16384 // 0x00004000
Constant ULong PRINTER_STATUS_READY = 0 // 0x00000000
Constant ULong PRINTER_STATUS_SERVER_UNKNOWN = 8388608 // 0x00800000
Constant ULong PRINTER_STATUS_TONER_LOW = 131072 // 0x00020000
Constant ULong PRINTER_STATUS_USER_INTERVENTION = 1048576 // 0x00100000
Constant ULong PRINTER_STATUS_WAITING = 8192 // 0x00002000
Constant ULong PRINTER_STATUS_WARMING_UP = 65536 // 0x00010000
end variables
on w_main.create
this.cb_process=create cb_process
this.cb_cancel=create cb_cancel
this.Control[]={this.cb_process,&
this.cb_cancel}
end on
on w_main.destroy
destroy(this.cb_process)
destroy(this.cb_cancel)
end on
type cb_process from commandbutton within w_main
integer x = 73
integer y = 64
integer width = 370
integer height = 132
integer taborder = 10
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
string text = "Process"
end type
event clicked;PRINTER_INFO_6 lstr_info
Boolean lb_return
Long ll_hPrinter
String ls_null, ls_DefaultPrinter, ls_Status
ULong lul_buffer, lul_needed
// Size the buffer
SetNull(ls_null)
GetDefaultPrinter(ls_null, lul_buffer)
ls_DefaultPrinter = Space(lul_buffer)
// Get the Windows default printer
lb_return = GetDefaultPrinter(ls_DefaultPrinter, lul_buffer)
// open the printer
lb_return = OpenPrinter(ls_DefaultPrinter, ll_hPrinter, 0)
// get the printer status
lb_return = GetPrinter(ll_hPrinter, 6, lstr_info, 8, lul_needed)
choose case lstr_info.dwStatus
case PRINTER_STATUS_READY
ls_Status = "Ready"
case else
ls_Status = "Unknown Status Code: " + String(lstr_info.dwStatus)
end choose
// close the printer
ClosePrinter(ll_hPrinter)
end event
type cb_cancel from commandbutton within w_main
integer x = 1682
integer y = 1216
integer width = 334
integer height = 100
integer taborder = 10
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
string text = "Cancel"
boolean cancel = true
end type
event clicked;Close(Parent)
end event
#define PRINTER_STATUS_BUSY 0x00000200
#define PRINTER_STATUS_DOOR_OPEN 0x00400000
#define PRINTER_STATUS_ERROR 0x00000002
#define PRINTER_STATUS_INITIALIZING 0x00008000
#define PRINTER_STATUS_IO_ACTIVE 0x00000100
#define PRINTER_STATUS_MANUAL_FEED 0x00000020
#define PRINTER_STATUS_NO_TONER 0x00040000
#define PRINTER_STATUS_NOT_AVAILABLE 0x00001000
#define PRINTER_STATUS_OFFLINE 0x00000080
#define PRINTER_STATUS_OUT_OF_MEMORY 0x00200000
#define PRINTER_STATUS_OUTPUT_BIN_FULL 0x00000800
#define PRINTER_STATUS_PAGE_PUNT 0x00080000
#define PRINTER_STATUS_PAPER_JAM 0x00000008
#define PRINTER_STATUS_PAPER_OUT 0x00000010
#define PRINTER_STATUS_PAPER_PROBLEM 0x00000040
#define PRINTER_STATUS_PAUSED 0x00000001
#define PRINTER_STATUS_PENDING_DELETION 0x00000004
#define PRINTER_STATUS_POWER_SAVE 0x01000000
#define PRINTER_STATUS_PRINTING 0x00000400
#define PRINTER_STATUS_PROCESSING 0x00004000
#define PRINTER_STATUS_SERVER_UNKNOWN 0x00800000
#define PRINTER_STATUS_TONER_LOW 0x00020000
#define PRINTER_STATUS_USER_INTERVENTION 0x00100000
#define PRINTER_STATUS_WAITING 0x00002000
#define PRINTER_STATUS_WARMING_UP 0x00010000
Just convert the hex numbers to ulong and make some constants.