
Thank you again for your help ABBKlaus.
It is using a Windows API, so that is unlikely.Any chance for a cross platform version of this?
Code: Select all
selprn$="Canon i550" ;valid printer but turned off
;selprn$="WorkForce 610(Network)" ;valid network printer online and working
;selprn$="Brother HL-1440 series" ;valid network printer out of paper
;selprn$="false printer test"
If Print_OpenPrinter(selprn$,"PAPERSIZE="+Str(#DMPAPER_LETTER)+",ORIENTATION="+Str(#DMORIENT_PORTRAIT),#PRINTER_ALL_ACCESS)
status=Print_GetStatus(#PRINT_STATUS)
If status<>0
If status & #PRINTER_STATUS_BUSY
Debug "#PRINTER_STATUS_BUSY"
EndIf
If status & #PRINTER_STATUS_DOOR_OPEN
Debug "#PRINTER_STATUS_DOOR_OPEN"
EndIf
If status & #PRINTER_STATUS_ERROR
Debug "#PRINTER_STATUS_ERROR"
EndIf
If status & #PRINTER_STATUS_INITIALIZING
Debug "#PRINTER_STATUS_INITIALIZING"
EndIf
If status & #PRINTER_STATUS_IO_ACTIVE
Debug "#PRINTER_STATUS_IO_ACTIVE"
EndIf
If status & #PRINTER_STATUS_MANUAL_FEED
Debug "#PRINTER_STATUS_MANUAL_FEED"
EndIf
If status & #PRINTER_STATUS_NO_TONER
Debug "#PRINTER_STATUS_NO_TONER"
EndIf
If status & #PRINTER_STATUS_NOT_AVAILABLE
Debug "#PRINTER_STATUS_NOT_AVAILABLE"
EndIf
If status & #PRINTER_STATUS_OFFLINE
Debug "#PRINTER_STATUS_OFFLINE"
EndIf
If status & #PRINTER_STATUS_OUT_OF_MEMORY
Debug "#PRINTER_STATUS_OUT_OF_MEMORY"
EndIf
If status & #PRINTER_STATUS_OUTPUT_BIN_FULL
Debug "#PRINTER_STATUS_OUTPUT_BIN_FULL"
EndIf
If status & #PRINTER_STATUS_PAGE_PUNT
Debug "#PRINTER_STATUS_PAGE_PUNT"
EndIf
If status & #PRINTER_STATUS_PAPER_JAM
Debug "#PRINTER_STATUS_PAPER_JAM"
EndIf
If status & #PRINTER_STATUS_PAPER_OUT
Debug "#PRINTER_STATUS_PAPER_OUT"
EndIf
If status & #PRINTER_STATUS_PAPER_PROBLEM
Debug "#PRINTER_STATUS_PAPER_PROBLEM"
EndIf
If status & #PRINTER_STATUS_PAUSED
Debug "#PRINTER_STATUS_PAUSED"
EndIf
If status & #PRINTER_STATUS_PENDING_DELETION
Debug "#PRINTER_STATUS_PENDING_DELETION"
EndIf
If status & #PRINTER_STATUS_POWER_SAVE
Debug "#PRINTER_STATUS_POWER_SAVE"
EndIf
If status & #PRINTER_STATUS_PRINTING
Debug "#PRINTER_STATUS_PRINTING"
EndIf
If status & #PRINTER_STATUS_PROCESSING
Debug "#PRINTER_STATUS_PROCESSING"
EndIf
If status & #PRINTER_STATUS_SERVER_UNKNOWN
Debug "#PRINTER_STATUS_SERVER_UNKNOWN"
EndIf
If status & #PRINTER_STATUS_TONER_LOW
Debug "#PRINTER_STATUS_TONER_LOW"
EndIf
If status & #PRINTER_STATUS_USER_INTERVENTION
Debug "#PRINTER_STATUS_USER_INTERVENTION"
EndIf
If status & #PRINTER_STATUS_WAITING
Debug "#PRINTER_STATUS_WAITING"
EndIf
If status & #PRINTER_STATUS_WARMING_UP
Debug "#PRINTER_STATUS_WARMING_UP"
EndIf
Else
Debug Print_GetLastError()
;I always get the message: The data area passed to a system call is too small.
EndIf
Else
Debug Print_GetLastError()
EndIf
Hi yrreti,yrreti wrote:Hi ABBKlaus
I really appreciate your library, and use it a lot in my programs.
But recently I saw need to be able to check the status of the list of installed printers,
so as to indicate any that were not available for use in the selection.
For example: printer is turned off, out of paper, paper jammed, out of ink, etc.
I tried using your Print_GetStatus(#PRINT_STATUS) to try to get that info, but all I get is
status = 0,
and Debug Print_GetLastError() always gives the message:
"The data area passed to a system call is too small" , even on valid online printers.
When I use the #PRINT_ATTRIBUTES type, it works fine. Different attributes are listed.
(I'm using PB4.61 on XP Pro)
I think I'm using the command right, but if not, could you please correct me as to
what I'm doing wrong? Thank you very much for any help or ideas.
Code: Select all
Printer-Lib Version V1.10
PureBasic Version 461
Printer : HPD134CF (HP Officejet Pro 8500 A910)
OpenPrinter_()=1
Print_SetTextAlign(0)
SetTextAlign_(4211253,0)=0
Print_SetBkMode(1)
SetBkMode_(4211253,1)=2
Print_SetLineColor(0)
Print_CreatePen(12200,0,0,0,0)
ExtCreatePen_(12200,5,18FEFC,0,0)=EE501649
Print_CreateBrush(0)
CreateSolidBrush_(0)=FF101451
Print_CreatePen(12200,0,0,0,0)
ExtCreatePen_(12200,5,18FF04,0,0)=835013CC
Status=16
Attribute=2624
#PRINTER_STATUS_PAPER_OUT
#PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST
#PRINTER_ATTRIBUTE_ENABLE_BIDI
#PRINTER_ATTRIBUTE_LOCAL
Code: Select all
#Win = 0
sOpt1.s = "ORIENTATION=" + Str(#DMORIENT_PORTRAIT) + Chr(44) + "PAPERSIZE=" + Str(#DMPAPER_A4) + Chr(44) + "PAPERLENGTH=297" + Chr(44) + "PAPERWIDTH=210" + Chr(44) + "SCALE=1" + Chr(44) + "COPIES=1" + Chr(44) + "DEFAULTSOURCE=" + Str(#DMBIN_AUTO) + Chr(44) + "PRINTQUALITY=" + Str(#DMRES_HIGH) + Chr(44) + "COLOR=" + Str(#DMCOLOR_COLOR) + Chr(44) + "COLLATE=" + Str(#DMCOLLATE_TRUE)
sOpt2.s = "FLAGS=" + "NFROMPAGE=1" + Chr(44) + "NTOPAGE=" + Str(igPageCnt) + Chr(44) + "NMINPAGE=1" + Chr(44) + "NMAXPAGE=999" + Chr(44) + "NCOPIES=1"
sJobName.s = "PP_" + Str(Date())
hDC = Print_PrintDlg(#Win,Print_GetDefaultPrinter(),sOpt1,sOpt2)
*PrintInfo.PRINTDLG = Print_GetPrintDlg()
Debug *PrintInfo\nFromPage
Debug *PrintInfo\nToPage
Debug *PrintInfo\nCopies
Debug Print_GetPrinterName()
Debug GetDeviceCaps_(hDC,#HORZRES)
Debug GetDeviceCaps_(hDC,#VERTRES)
Debug Print_GetDeviceCaps(#HORZRES)
Debug Print_GetDeviceCaps(#VERTRES)
End
Code: Select all
#Win = 0
#Prt = 1
If OpenWindow(#Win,0,0,200,200,"Test",#PB_Window_SystemMenu|#PB_Window_TitleBar)
sOpt1.s = "ORIENTATION=" + Str(#DMORIENT_PORTRAIT) + Chr(44) + "PAPERSIZE=" + Str(#DMPAPER_A4) + Chr(44) + "PAPERLENGTH=297" + Chr(44) + "PAPERWIDTH=210" + Chr(44) + "SCALE=1" + Chr(44) + "COPIES=1" + Chr(44) + "DEFAULTSOURCE=" + Str(#DMBIN_AUTO) + Chr(44) + "PRINTQUALITY=" + Str(#DMRES_HIGH) + Chr(44) + "COLOR=" + Str(#DMCOLOR_COLOR) + Chr(44) + "COLLATE=" + Str(#DMCOLLATE_TRUE)
sOpt2.s = "FLAGS=" + "NFROMPAGE=1" + Chr(44) + "NTOPAGE=" + Str(igPageCnt) + Chr(44) + "NMINPAGE=1" + Chr(44) + "NMAXPAGE=999" + Chr(44) + "NCOPIES=1"
sJobName.s = "PP_" + Str(Date())
hDC = Print_PrintDlg(#Prt,Print_GetDefaultPrinter(),sOpt1,sOpt2)
*PrintInfo.PRINTDLG = Print_GetPrintDlg()
Debug *PrintInfo\nFromPage
Debug *PrintInfo\nToPage
Debug *PrintInfo\nCopies
Debug Print_GetPrinterName()
hDC = Print_OpenPrinter(Print_GetPrinterName())
Debug Print_GetPrinterName()
Debug GetDeviceCaps_(hDC,#HORZRES)
Debug GetDeviceCaps_(hDC,#VERTRES)
Debug Print_GetDeviceCaps(#HORZRES)
Debug Print_GetDeviceCaps(#VERTRES)
EndIf
End
Code: Select all
Procedure.s GetSelectedPrinter()
;-------------------------------
Protected sPrinterName.s, PrintDlg.PRINTDLG, *DEVNAMES.DEVNAMES
With PrintDlg
\lStructSize = SizeOf(PRINTDLG)
\Flags = #PD_ALLPAGES
EndWith
PrintDlg_(PrintDlg)
*DEVNAMES = GlobalLock_(PrintDlg\hDevNames)
sPrinterName = PeekS(*DEVNAMES + (*DEVNAMES\wDeviceOffset * SizeOf(Character))) ;wDeviceOffset is in characters, not bytes
GlobalUnlock_(PrintDlg\hDevNames)
GlobalFree_(PrintDlg\hDevNames)
ProcedureReturn sPrinterName
EndProcedure