BOOL EnumPrinters(Type, Name, Level, pPrinterEnum, cbBuf, pcbNeeded, pcReturned) | |||
DWORD Type; | |||
LPTSTR Name; | |||
DWORD Level; | |||
LPBYTE pPrinterEnum; | |||
DWORD cbBuf; | |||
LPDWORD pcbNeeded; | |||
LPDWORD pcReturned; |
The EnumPrinters function enumerates the Printers that are available for printing to.
Type
Specifies whether the enumeration should include local printers, desktop printers and/or network printers. Type is defined as a set of bit Type. This allows an application to specify any combination of these types of printers to be enumerated.
A local printer is one that is physically attached to the user's computer. A desktop is one that the user has indicated is frequently used. A network printer is one that the network vendor defines as such. For example, Lan Manager may define all printers in the user's network domain as network printers.
The following values have meaning:
#define PRINTER_ENUM_DEFAULT 0x00000001
#define PRINTER_ENUM_LOCAL 0x00000002
#define PRINTER_ENUM_FAVORITE 0x00000004
#define PRINTER_ENUM_NAME 0x00000008
#define PRINTER_ENUM_REMOTE 0x00000010
#define PRINTER_ENUM_SHARED 0x00000020
Value | Meaning |
PRINTER_ENUM_DEFAULT | Return the default Printer |
PRINTER_ENUM_LOCAL | Return locally installed printers. |
PRINTER_ENUM_FAVORITE | Return a list of favorite printers. This is essentially the list of Printers that the user has made previous connections to. |
PRINTER_ENUM_NAME | This performs the enumeration on the specified Name. This could be a server name, or a domain name. |
PRINTER_ENUM_REMOTE | Return network printers. |
PRINTER_ENUM_SHARED | Return only the Printers that have an attribute of shared. |
Name
A Pointer to a null-terminated string specifying the location at which the enumeration should be performed. This can be NULL.
Level
This value must be 1, or 2.
pPrinterEnum
If the level is 2, then an array of PRINTER_INFO_2 structures is returned.
If the level is 1, then an array of PRINTER_INFO_1 structures is returned.
cbBuf
The size in bytes of the buffer pointed to by pPrinterEnum.
pcbNeeded
This points to a variable that will be updated to contain the actual buffer size required that is pointed to by pPrinterEnum. If cbBuf is too small then GetLastError will indicate ERROR_BUFFER_TOO_SMALL, and pcbNeeded will contain the size required. If cbBuf is large enough, then pcbNeeded will contain the number of bytes that were copied.
pcReturned
Pointer to a DWORD that the function will set to the number of printers enumerated.
The return value is TRUE if the function was successful, or FALSE if an error occurred. To obtain extended error information, use the GetLastError function.
AddPrinter, DeletePrinter, GetPrinter, SetPrinter