BOOL (WINAPI *pfnEnumPorts)(
LPWSTR pName, | |
DWORD Level, | |
LPBYTE pPorts, | |
DWORD cbBuf, | |
LPDWORD pcbNeeded, | |
LPDWORD pcReturned | |
); |
EnumPorts enumerates the ports available for printing on a specified server.
The return value is TRUE if the function is successful; otherwise, it is FALSE.
The spooler calls EnumPorts to get the list of ports maintained by a monitor. At spooler initialization, the spooler calls EnumPorts for all installed print monitors to build up a list of all available ports. The spooler expects valid results from EnumPorts regardless of whether a printer has yet been defined.
If a monitor doesn’t support the structure specified by Level, EnumPorts should log an ERROR_INVALID_LEVEL error and fail.
If cbBuf is too small, EnumPorts should set ERROR_INSUFFICIENT_BUFFER, and return in pcbNeeded the number of bytes required to copy all of the data. If cbBuf is large enough, EnumPorts should return the number of bytes copied into pPorts.
EnumPorts must write the PORT_INFO_Xx structure(s) at the beginning of the pPorts buffer, and the string(s) associated with the PORT_INFO_Xx structure(s) at the end of the buffer. Monitors that do not pack data in this way will cause Win32 EnumPorts calls to the spooler to fail. See the localmon code for an example of how to pack the pPorts buffer.
Monitors should set the pMonitorName field of the PORT_INFO_2 structure to be a string that describes their monitor. It is the monitor’s responsibility to localize this string. Monitors should set PORT_INFO_2’s fPortType field to zero.
EnumPorts is a port management function that must be implemented by port monitors and LMPMs. Pure language monitors should not implement this function.