'============================================================================== ' Network Resource List for PBWin 7.04 ' Copyright (c) 1998 by PowerBASIC, Inc. ' Updated for PB/CC 2.0 - Feb 2001 by Wayne Diamond ' Enumerate all of the networks and network resources available to the ' current machine. '============================================================================== '[keywords] Network resources, WNetEnumResource, xPrint #DIM ALL #COMPILE EXE #INCLUDE "WIN32API.INC" GLOBAL xOut() AS STRING SUB xPrint(OPT BYVAL s AS STRING) STATIC numOut AS LONG INCR numOut: REDIM PRESERVE xOut(numOut) xOut(numOut) = s END SUB SUB xPrintAll() LOCAL hOutput AS LONG, x AS LONG, y AS LONG, i AS LONG DIALOG NEW 0, "Example", , , 270, 200, %WS_SYSMENU TO hOutput DIALOG GET CLIENT hOutput TO x, y CONTROL ADD LISTBOX, hOutput, 9999, xOut(), 0, 0, x, y, %WS_VSCROLL FOR i = 1 TO UBOUND(xOut) LISTBOX ADD hOutput, 9999, xOut(i) NEXT i DIALOG SHOW MODAL hOutput END SUB SUB EnumAll (nr AS NETRESOURCE) LOCAL hEnum AS LONG LOCAL Entries AS LONG LOCAL nSize AS LONG LOCAL ec AS LONG LOCAL x AS LONG STATIC s AS STRING DIM n(1 TO 256) AS NETRESOURCE Entries = 256 nSize = SIZEOF(nr) * Entries s = s + " " ec = WNetOpenEnum(%RESOURCE_GLOBALNET, %RESOURCETYPE_ANY, %NULL, nr, hEnum) ec = WNetEnumResource(hEnum, Entries, n(1), nSize) FOR x = 1 TO Entries xPrint LEFT$(s & n(x).@lpRemoteName + SPACE$(40), 40) + n(x).@lpComment IF (n(x).dwUsage AND %RESOURCEUSAGE_CONTAINER) THEN EnumAll n(x) END IF NEXT s = LEFT$(s, LEN(s) - 2) END SUB FUNCTION PBMAIN() AS LONG LOCAL u AS ASCIIZ * 256, hOutput AS DWORD GetUserName u, 256 xPrint "Network Resource List for " & u xPrint "Copyright (c) 1998 by PowerBASIC, Inc." xPrint EnumAll BYVAL %NULL xPrintAll END FUNCTION