The EnumPorts function enumerates the ports that are available for printing on a specified server.
BOOL EnumPorts(
LPTSTR pName, // pointer to server name
DWORD Level, // specifies type of port info structure
LPBYTE pPorts, // pointer to buffer to receive array of port
// info. structures
DWORD cbBuf, // specifies size, in bytes, of buffer
LPDWORD pcbNeeded, // pointer to number of bytes stored into
// buffer (or required buffer size)
LPDWORD pcReturned // pointer to number of PORT_INFO_*.
// structures stored into buffer
);
If pName is NULL, the function enumerates the local machine's printer ports.
This value can be 1 or 2.
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.
The EnumPorts function can succeed even if the server specified by pName does not have a printer defined.
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in winspool.h.
Import Library: Use winspool.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT.
Printing and Print Spooler Overview, Printing and Print Spooler Functions, AddPort, DeletePort, PORT_INFO_1, PORT_INFO_2