xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

PrinterPortToName()

Retrieves the name of the printer connected to a printer port.

Syntax

PrinterPortToName( <cPortName> ) --> cPrinterName

Arguments

<cPortName>
This is a character string holding the port name where a printer is connected to.

Return

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.

Description

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:".

Info

See also:GetPrinters(), GetDefaultPrinter(), IsPrinter(), PrinterExists()
Category: Printer functions , xHarbour extensions
Source:rtl\tprinter.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// 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

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe