The EnumPrinters function enumerates available printers, print servers, domains, or print providers.
BOOL EnumPrinters(
DWORD Flags, |
// types of printer objects to enumerate |
LPTSTR Name, |
// name of printer object |
DWORD Level, |
// specifies type of printer info structure |
LPBYTE pPrinterEnum, |
// pointer to buffer to receive printer info structures |
DWORD cbBuf, |
// size, in bytes, of array |
LPDWORD pcbNeeded, |
// pointer to variable with no. of bytes copied (or required) |
LPDWORD pcReturned |
// pointer to variable with no. of printer info. structures copied |
); |
Value |
Meaning |
PRINTER_ENUM_LOCAL |
The function ignores the Name parameter, and enumerates the locally installed printers. Windows 95: The function will also enumerate network printers because they are handled by the local print provider. |
PRINTER_ENUM_NAME |
The function enumerates the printer identified by Name. This can be a server, a domain, or a print provider. If Name is NULL, the function enumerates available print providers. |
PRINTER_ENUM_SHARED |
The function enumerates printers that have the shared attribute. Cannot be used in isolation; use an OR operation to combine with another PRINTER_ENUM type. |
PRINTER_ENUM_DEFAULT |
Windows 95 only: The function returns information about the default printer. |
PRINTER_ENUM_CONNECTIONS |
Windows NT only: The function enumerates the list of printers to which the user has made previous connections. |
PRINTER_ENUM_NETWORK |
Windows NT only: The function enumerates network printers in the computer’s domain. This value is valid only if Level is 1. |
PRINTER_ENUM_REMOTE |
Windows NT only: The function enumerates network printers and print servers in the computer’s domain. This value is valid only if Level is 1. |
If Level is 4, you can only use the PRINTER_ENUM_CONNECTIONS and
PRINTER_ENUM_LOCAL constants.
If Level is 1, Flags contains PRINTER_ENUM_NAME, and Name is NULL, the function enumerates the available print providers.
If Level is 1, Flags contains PRINTER_ENUM_REMOTE, and Name is NULL, the function enumerates the printers in the user’s domain.
If Level is 2 or 5, Name points to a null-terminated string that specifies the name of a server whose printers are to be enumerated. If this string is NULL, the function enumerates the printers installed on the local machine.
If Level is 4, Name should be NULL. The function always queries on the local machine.
When Name is NULL, it 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.
Windows 95: The value can be 1, 2, or 5.
Windows NT: This value can be 1, 2, 4, or 5.
Windows 95: The buffer cannot receive PRINTER_INFO_4 structures.
It can receive any of the other types.
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
If EnumPrinters returns a PRINTER_INFO_1 structure in which PRINTER_ENUM_CONTAINER is specified, this indicates that there is a hierarchy of printer objects. An application can enumerate the hierarchy by calling EnumPrinters again, setting Name to the value of the PRINTER_INFO_1 structure’s pName member.
The EnumPrinters function does not retrieve security information. If PRINTER_INFO_2 structures are returned in the array pointed to by pPrinterEnum, their pSecurityDescriptor members will be set to NULL.
To get information about the default printer, call the GetProfileString function with the section name string set to "windows" and the key name string set to "device". The returned string contains the name of the default printer, the name of the printer DRV file, and the port to which the printer is attached.
The following table shows the EnumPrinters output for various Flags values when the Level parameter is set to 1.
In the Name parameter column of the table, you should substitute an appropriate name for Print Provider, Domain, and Machine. For example, for Print Provider, you could use the name of the Windows NT network print provider: “Windows NT Remote Printers”, or the name of the Windows 95 local print provider: “Windows 95 Local Print Provider”. To get print provider names, call EnumPrinters with Name set to NULL.
Flags parameter |
Name parameter |
Result |
PRINTER_ENUM_LOCAL |
The Name parameter is ignored. |
All local printers. Windows 95: Also enumerates network printers because they are installed locally. |
PRINTER_ENUM_NAME |
“Print Provider” |
All domain names |
PRINTER_ENUM_NAME |
Windows NT only: |
All printers and print servers in the computer’s domain |
PRINTER_ENUM_NAME |
Windows NT only: |
All printers shared at \\Machine |
PRINTER_ENUM_NAME |
Windows NT: An empty string, ““ Windows 95: The name of the local machine or the local print provider. |
All local printers. Windows 95: Also enumerates network printers because they are installed locally. |
PRINTER_ENUM_NAME |
NULL |
All print providers in the computer’s domain |
Windows NT only: |
The Name parameter is ignored. |
All connected remote printers |
Windows NT only: |
The Name parameter is ignored. |
All printers in the computer’s domain |
Windows NT only: |
An empty string, ““ |
All printers and print servers in the computer’s domain |
Windows NT only: |
“Print Provider” |
Same as PRINTER_ENUM_NAME |
Windows NT only: |
“Print Provider!Domain” |
All printers and print servers in computer’s domain, regardless of Domain specified. |
AddPrinter, DeletePrinter, GetPrinter, GetProfileString, PRINTER_INFO_1, PRINTER_INFO_2, PRINTER_INFO_4, PRINTER_INFO_5, SetPrinter
file: /Techref/os/win/api/win32/func/src/f21_4.htm, 16KB, , updated: 2000/4/7 11:19, local time: 2024/11/5 11:22,
3.135.190.224:LOG IN ©2024 PLEASE DON'T RIP! THIS SITE CLOSES OCT 28, 2024 SO LONG AND THANKS FOR ALL THE FISH!
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://massmind.org/techref/os/win/api/win32/func/src/f21_4.htm"> EnumPrinters</A> |
Did you find what you needed? |
Welcome to massmind.org! |
Welcome to massmind.org! |
.