Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: View/Pro and accessing Windows Printer API (gdi32.dll)

From: amicom:sonic at: 1-Jul-2002 9:41

Gregg, Your solution does return an apparently valid handle when I apply it to OpenPrinter, but StartDocPrinter still doesn't like it (returns a code of 6 which means "invalid handle"). Here's my script so far (beware of line-wrapping!): winspool: load/library %winspool.drv kernel32: load/library %kernel32.dll print "Define GetLastError" getlasterror: make routine! [ return: [long] ] kernel32 "GetLastError" print "Define OpenPrinter" openprinter: make routine! [ "Open Printer" pprintername [string!] phprinter [char*] pdefault [string!] return: [integer!] ] winspool "OpenPrinterA" print "Define StartDocPrinter" startdocprinter: make routine! [ "StartDocPrinter" hprinter [char*] dwlevel [int] lpbdocinfo [struct! [ cbsize [int] lpszdocname [string!] lpszoutput [string!] lpszdatatype [string!] fwtype [int] ]] return: [int] ] winspool "StartDocPrinterA" print {Create a Null Buffer - Thanks to Gregg Irwin and Gabrielle Santilli on REBOL list} null-buff: func [len][ head insert/dup make string! len #"^(00)" len ] print {Create Pointer Variable - Thanks again to Gregg Irwin} prin "Initial value: " probe to-binary hprinter: null-buff 4 print "Create DocInfo Struct" docinfo: make struct! [ cbsize [int] lpszdocname [string!] lpszoutput [string!] lpszdatatype [string!] fwtype [int] ][100 "Test Print" "" "" 0] print "Call OpenPrinter" print either zero? ret: openprinter "Brother MFC3100C" hprinter "" ["FAIL!"]["Success"] prin "Current value: " probe to-binary hprinter print "Call StartDocPrinter" print either zero? dwjob: startdocprinter hprinter 1 docinfo [["ERROR!" getlasterror]]["SUCCESS!"] halt If anyone has suggestions on why StartDocPrinter doesn't like the handle, I'd be very curious to find out! Thanks for all the help so far. I'm hoping that someday REBOL users can have graphical access to printers. I know it would make my applications a lot more useful! -Bo At 09:23 AM 6/29/02 -0600, you wrote: