Stores information about available printers, print servers, domains, or print providers into an array.

APrintersEx(cArrayName [, cName [, nFlags [, nLevel [, nOutputType]]]])

Parameters

cArrayName

if nLevel = 1

the array contains the following information from the PRINTER_INFO_1 structure.
ColumnContentDatatype
1Flags. Have a look here PRINTER_INFO_1 for a list of possible values.N
2Describes the contents of the structure.C
3Names the contents of the structure.C
4Additional data describing the structure.C


if nLevel = 2

the array contains the following information from the PRINTER_INFO_2 structure.
ColumnContentDatatype
1The server that controls the printer. If this string is empty, the printer is controlled locally.C
2The name of the printer.C
3The share point for the printer.C
4The port(s) used to transmit data to the printer.C
5The name of the printer driver.C
6A brief description of the printer.C
7Specifies the physical location of the printerC
8The name of the file used to create the separator page. This page is used to separate print jobs sent to the printer.C
9The name of the print processor used by the printer. C
10The data type used to record the print job.C
11The default print-processor parameters.C
12The printer attributes. For a list of possible values have a look here PRINTER_INFO_2.N
13A priority value that the spooler uses to route print jobs.N
14The default priority value assigned to each print job.N
15The earliest time at which the printer will print a job.
This value is expressed as minutes elapsed since 12:00 AM GMT (Greenwich Mean Time).
N
16The latest time at which the printer will print a job.
This value is expressed as minutes elapsed since 12:00 AM GMT (Greenwich Mean Time).
N
17The printer status. For a list of possible values have a look here PRINTER_INFO_2.C
18The number of print jobs that have been queued for the printer.N
19The average number of pages per minute that have been printed on the printer.N


if nLevel = 4

the array contains the following information from the PRINTER_INFO_4 structure.
ColumnContentDatatype
1The name of the printer (local or remote).C
2The name of the server.C
3Attributes. For a list of possible values have a look here PRINTER_INFO_4.N


if nLevel = 5

the array contains the following information from the PRINTER_INFO_5 structure.
ColumnContentDatatype
1The name of the printer.C
2The port(s) used to transmit data to the printer.C
3The printer attributes. For a list of possible values have a look here PRINTER_INFO_5.N
4DeviceNotSelectedTimeoutN
5TransmissionRetryTimeoutN
cName (optional)

default = empty

Name of the print processor, domain or server for which to enumerater printers.

if nLevel is 1, nFlags contains PRINTER_ENUM_NAME and cName is not empty, then cName specifies the name of the object to enumerate.
This string can be the name of a server, a domain, or a print provider.

if nLevel is 1, nFlags contains PRINTER_ENUM_NAME, and cName is empty, then the function enumerates the available print providers.

if nLevel is 1, nFlags contains PRINTER_ENUM_REMOTE, and cName is empty, then the function enumerates the printers in the user's domain.

If nLevel is 2 or 5, cName specifies the name of a server whose printers are to be enumerated. If cName is empty, then the function enumerates the printers installed on the local machine.

If nLevel is 4, cName should be empty. The function always queries on the local machine.

When cName is empty, setting nFlags to PRINTER_ENUM_LOCAL + PRINTER_ENUM_CONNECTIONS enumerates printers that are installed on the local machine. These printers include those that are physically attached to the local machine as well as remote printers to which it has a network connection.

nFlags (optional, additive)

default = PRINTER_ENUM_LOCAL

One or a combination of the following values.
FlagDescription
PRINTER_ENUM_LOCALThe function ignores the cName parameter, and enumerates the locally installed printers.
Windows 95/98/Me: The function will also enumerate network printers because they are handled by the local print provider.
PRINTER_ENUM_NAMEThe function enumerates the printer identified by cName. This can be a server, a domain, or a print provider. If cName is empty, the function enumerates available print providers.
PRINTER_ENUM_SHAREDThe function enumerates printers that have the shared attribute.
Cannot be used in isolation; use an + operation to combine with another PRINTER_ENUM type.
PRINTER_ENUM_DEFAULTWindows 95/98/Me: The function returns information about the default printer.
PRINTER_ENUM_CONNECTIONSWindows NT/2000/XP: The function enumerates the list of printers to which the user has made previous connections.
PRINTER_ENUM_NETWORKWindows NT/2000/XP: The function enumerates network printers in the computer's domain. This value is valid only if nLevel is 1.
PRINTER_ENUM_REMOTEWindows NT/2000/XP: The function enumerates network printers and print servers in the computer's domain. This value is valid only if nLevel is 1.
nLevel (optional)

default = 2

Specifies the level of intormation returned by the function,

Valid values are 1, 2, 4, and 5, which correspond to the PRINTER_INFO_1, PRINTER_INFO_2, PRINTER_INFO_4, and PRINTER_INFO_5 data structures.

Windows 95/98/Me: The value can be 1, 2, or 5.
Windows NT/2000/XP: This value can be 1, 2, 4, or 5.

nOutputType (optional)

default = APRINT_OUTPUT_ARRAY

Valid values.
APRINT_OUTPUT_ARRAY - the information is returned in a multidimenional array
APRINT_OUTPUT_OBJECTARRAY - the information is returned in a single dimension array, where each row holds an object with custom set properties

Return Value

The number of printers.

See Also

Reference

APaperSizes
APrinterForms
APrinterTrays
APrintJobs

Used WinApi functions

EnumPrinters