Partager via


APRINTERS( ) Function

Places the names of printers currently installed in the Windows Print Manager into a variable array.

APRINTERS(ArrayName)

Return Values

Numeric

Parameters

  • ArrayName
    Specifies the name of the array containing the names of the installed printers and their ports. If the array you include doesn't exist, Visual FoxPro automatically creates the array. If the array exists and isn't large enough to contain all the printer information, Visual FoxPro automatically increases the size of the array to accommodate the information. If the array is larger than necessary, Visual FoxPro truncates the array. If the array exists and APRINTERS( ) returns 0 because no printers are installed, the array remains unchanged. If the array doesn't exist and APRINTERS( ) returns 0, the array isn't created.

Remarks

APRINTERS( ) creates a two-dimensional array. The first column of the array contains the names of the currently installed printers, and the second column contains the ports to which the printers are connected.

APRINTERS( ) returns the number of installed printers. If no printer is installed, it returns 0.

Visual FoxPro obtains the names of the installed printers and their ports from Windows. However, Visual FoxPro doesn't check to see if the printers are actually connected to your machine.

Example

The following example uses APRINTERS( ) to create an array named gaPrinters that contains the names and ports of installed printers. The printers and their ports are then displayed. If no printer is installed, a message is displayed.

IF APRINTERS(gaPrinters) > 0  && If there are installed printer drivers
   CLEAR  && Clear the main Visual FoxPro window
   DISPLAY MEMORY LIKE gaPrinters && Display the printers and ports
ELSE  && Otherwise, no printer are installed
   WAIT WINDOW 'No printers installed.'
ENDIF

See Also

GETPRINTER( ) | PRINTSTATUS( ) | PRTINFO( ) | SET PRINTER