Skip to Content
0

winspool.drv openprinter issue

Jan 08, 2017 at 02:12 AM

110

avatar image
Former Member

I'm trying to use external function OpenPrinterA, but it

keeps failing.

Local external function is:

Function Long WritePrinterB(Long Handle, Ref Blob pData, Long pDataLen, Ref Long BytesWritten) Library "winspool.drv" Alias For "WritePrinter;ansi"

FUNCTION long GetErrMessage (Long dwFlags ,ref Any lpSource , Long dwMessageId, Long dwLanguageId, ref String lpBuffer, Long nSize , Long Arguments) LIBRARY "kernel32.dll" ALIAS FOR "FormatMessageA"

Function Long OpenPrinter(String PrinterName, Ref Long Handle, Long Defaults) library "winspool.drv" alias for "OpenPrinterA"

Function Long ClosePrinter(Long Handle) Library "winspool.drv"

Function Long WritePrinter(Long Handle, Ref Char pData[], Long pDataLen, Ref Long BytesWritten) Library "winspool.drv" Alias For "WritePrinter;ansi"

Function Long WritePrinterS(Long Handle, Ref String pData, Long pDataLen, Ref Long BytesWritten) Library "winspool.drv" Alias For "WritePrinter;ansi"

Function Long StartPagePrinter(Long Handle) Library "winspool.drv"

Function Long EndPagePrinter(Long Handle) Library "winspool.drv"

Function Long EndDocPrinter(Long Handle) Library "winspool.drv"

Function Long AbortPrinter(Long Handle) Library "winspool.drv"

Function Long GetLastError() Library "Kernel32.dll"

Function Long StartDocPrinter(Long Handle, Long Level, Ref DocInfo DI) Library "winspool.drv" alias for "StartDocPrinterW"

of_print()

Long PrinterHandle

li_ret = OpenPrinter(as_printer,PrinterHandle,0)

If li_ret <> 0 then

Return li_ret

End If



li_ret

is always 0. What am I doing wrong?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

avatar image
Former Member Jan 08, 2017 at 02:37 AM
0

You are using OpenPrinterA without specifying ansi. Try changing it to OpenPrinterW.

Share
10 |10000 characters needed characters left characters exceeded