Announcement

Collapse
No announcement yet.

Working Routine Using WNetEnumResource?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Working Routine Using WNetEnumResource?

    Does anyone have a working routine that uses WNetEnumResource to
    return the names of the connected network machines (\\Server1,
    \\Server2, ...)? I found several examples of functions using
    WNetEnumResource but none of them for PBDLL 6.0 and none of them
    seem actually work.

    I have a working routine in VB but I have not been able to convert
    it to PBDLL 6.0.


    ------------------
    Thanks,

    Doug Gamble
    mailto:[email protected][email protected]</A>
    Thanks,

    Doug Gamble
    [email protected]

  • #2
    Code:
    '==============================================================================
    '  Network Resource List for PB/DLL 5.0
    '  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.
    '==============================================================================
     
    $DIM ALL
    $COMPILE EXE 'PB/CC 2.0
    $INCLUDE "WIN32API.INC"
    GLOBAL hOutput AS LONG
     
    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
        STDOUT LEFT$(s & n(x)[email protected] + SPACE$(40), 40) + n(x)[email protected]
        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 = GetStdHandle(%STD_OUTPUT_HANDLE)
      GetUserName u, 256
      STDOUT "Network Resource List for " & u
      STDOUT "Copyright (c) 1998 by PowerBASIC, Inc."
      STDOUT ""
      EnumAll BYVAL %NULL
    END FUNCTION

    ------------------
    -

    Comment


    • #3
      Thanks Wayne...That did the trick!


      ------------------
      Thanks,

      Doug Gamble
      mailto:[email protected][email protected]</A>
      Thanks,

      Doug Gamble
      [email protected]

      Comment

      Working...
      X