EnumPorts

  BOOL EnumPorts(pName, Level, pPorts, cbBuf, pcbNeeded, pcReturned)    
  LPSTR pName;    
  DWORD Level;    
  LPBYTE pPorts;    
  DWORD cbBuf;    
  LPDWORD pcbNeeded;    
  LPDWORD pcReturned;    

This function Enumerates the available Ports that a Printer can be connected to.

Parameters

pName

Points to a NULL terminated string specifying the Server that the Ports reside on. If NULL, then the Ports available locally are returned.

Level

This value must be 1.

pPorts

This points to a buffer that will be filled with an array of PORT_INFO_1 structures.

cbBuf

Specifies the size of the buffer pointed to by pPorts.

pcbNeeded

This points to a variable that will be updated to contain the actual buffer size required that is pointed to by pPorts. 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

Points to a variable that will contain the number of PORT_INFO_1 structures returned in pPorts.

Return Value

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.