xHarbour Reference Documentation > Function Reference |
Retrieves information about available printers.
GetPrinters( [<lPortInfo>], [<lLocalPrinters>] ) --> aPrinterInfo
The function returns a one- or two-dimensional array. If <lPortInfo> is .F. (false), a one-dimensional array is returned. Each element contains a character string with the name of an available printer. If <lPortInfo> is .T., each element of the returned array is an array of four elements, holding character strings with additional printer information:
Array elements for additional printer information
Element | Description |
---|---|
1 | Printer name |
2 | Port name |
3 | Printer type (e.g. Local/Network) |
4 | Printer driver |
The GetPrinters() function obtains information about printers that are currently available. If it is called without arguments, the function returns the names of all available printers. The list can be reduced to local printers only by specifying .T. (true) for <lLocalPrinters>. Additional information about port and printer driver can be retrieved when <lPortInfo> is set to .T. (true)
See also: | GetDefaultPrinter(), PrintFileRaw(), PrinterExists(), PrinterPortToName() |
Category: | Printer functions , xHarbour extensions |
Source: | rtl\tprinter.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example is a test program for Windows printing PROCEDURE Main LOCAL aPrinter, i CLS ? ? Set(_SET_DEVICE) aPrinter := GetPrinters() IF Empty( aPrinter ) ? '----- No Printers installed' QUIT ENDIF SET PRINTER TO ( GetDefaultPrinter() ) ? Set( _SET_PRINTER ) ? Set( _SET_PRINTFILE ) SET CONSOLE OFF SET PRINTER ON ? 'Default Printer' ? ? GetDefaultPrinter() ? ? 'Printers available' ?'-------------------' FOR i:= 1 TO Len( aPrinter ) ? aPrinter[i] NEXT i aPrinter:= GetPrinters( .T. ) ? ? 'Printers and Ports' ? '-------------------' FOR i:= 1 TO Len( aPrinter ) ? aPrinter[i,1],'on', aPrinter[i,2] NEXT EJECT SET PRINTER OFF SET CONSOLE ON SET PRINTER TO ? Set( _SET_PRINTER ) ? Set( _SET_DEVICE ) WAIT RETURN
http://www.xHarbour.com