The following example enumerates the ports that are available for printing on the local server.
' ########################################################################################
' The following example enumerates the ports that are available for printing on the local server.
' ########################################################################################
' CSED_PBCC - Use the PBCC compiler
#COMPILE EXE
#DIM ALL
#INCLUDE "windows.inc"
' ========================================================================================
' Main
' ========================================================================================
FUNCTION PBMAIN () AS LONG
LOCAL cbNeeded AS LONG
LOCAL cReturned AS LONG
LOCAL i AS LONG
DIM Ports(0) AS PORT_INFO_1
EnumPorts(BYVAL %NULL, 1, BYVAL %NULL, 0, cbNeeded, cReturned)
IF cbNeeded THEN
REDIM Ports(0 TO cbNeeded \ SIZEOF(PORT_INFO_1))
EnumPorts BYVAL %NULL, 1, Ports(0), _
SIZEOF(Ports(0)) * (UBOUND(Ports) + 1), cbNeeded, cReturned
PRINT " #", "Port name"
PRINT " -", "---------"
FOR i = 0 TO cReturned - 1
PRINT i, Ports(i).@pName
NEXT
END IF
WAITKEY$
END FUNCTION
' ========================================================================================