| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Retrieves the name of the printer connected to a printer port.
PrinterPortToName( <cPortName> ) --> cPrinterName
The function returns a character string holding the name of a printer, or an empty string ("") if the port name does not exist or no printer is connected to the specified port.
Function PrinterPortToName() retrieves the name of the printer which is connected to the port <cPortName>. The port name must be specified including the colon, like "LPT1:".
| See also: | GetPrinters(), GetDefaultPrinter(), IsPrinter(), PrinterExists() |
| Category: | Printer functions , xHarbour extensions |
| Source: | rtl\tprinter.c |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The example queries the printer ports LPT1: to LPT5: and
// lists the names of connected printers
PROCEDURE Main()
LOCAL aPrinters := {}
LOCAL i, cPrinter, cPort
FOR i:=1 TO 5
cPort := "LPT" + LTrim( Str(i) ) + ":"
cPrinter := PrinterPortToName( cPort )
IF .NOT. Empty( cPrinter )
AAdd( aPrinters, { cPort, cPrinter } )
ENDIF
NEXT
IF Empty( aPrinters )
? "No printer found"
ELSE
AEval( aPrinters, {|a| Qout( a[1], a[2] ) } )
ENDIF
RETURN
http://www.xHarbour.com