IT-Consultant: José Roca (PBWIN 10+/PBCC 6+) (Archive only) > GDI

GDI: EnumPorts Function

(1/1)

José Roca:
 
The following example enumerates the ports that are available for printing on the local server.


--- Code: ---' ########################################################################################
' 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
' ========================================================================================

--- End code ---

Navigation

[0] Message Index

Go to full version