Page 2 of 2

Posted: Sun May 09, 2004 11:23 am
by ABBKlaus
is i mentioned above the Buffer is essential !!!
without the Buffer you get error number 487 = ERROR_INVALID_ADDRESS

for information see the MSDN at http://msdn.microsoft.com/library/defau ... ources.asp

have fun with this :

Code: Select all

; '============================================================================== 
; '  Network Resource List. 
; '  Enumerate all of the networks and network resources available to the 
; '  current machine. 
; ' converted using http://www.powerbasic.com/support/forums/Forum6/HTML/001494.html 
; '============================================================================== 
#Window_Main = 0 
#Gadget_ListIcon = 0 

Structure NEWNETRESOURCE
  Scope.s
  Type.s
  DisplayType.s
  Usage.s
  LocalName.s
  RemoteName.s
  Comment.s
  Provider.s
EndStructure

NewList ListNETRESOURCE.NEWNETRESOURCE()

Procedure EnumAll(*nr.NETRESOURCE) 
  tempnr.NETRESOURCE
  j.l
  x.l
  Entries = -1 
  nSize = 16384
  *Buffer=AllocateMemory(nSize) 
  ec = WNetOpenEnum_(#RESOURCE_GLOBALNET, #RESOURCETYPE_ANY, #NULL, *nr, @hEnum) 
  If hEnum 
      ec = WNetEnumResource_(hEnum, @Entries, *Buffer, @nSize) 
      For x = 1 To Entries 
        j = (x-1) * SizeOf(NETRESOURCE)
        tempnr\dwScope        = PeekL(*Buffer+j+0) 
        tempnr\dwType         = PeekL(*Buffer+j+4) 
        tempnr\dwDisplayType  = PeekL(*Buffer+j+8) 
        tempnr\dwUsage        = PeekL(*Buffer+j+12) 
        tempnr\lpLocalName    = PeekL(*Buffer+j+16) 
        tempnr\lpRemoteName   = PeekL(*Buffer+j+20) 
        tempnr\lpComment      = PeekL(*Buffer+j+24) 
        tempnr\lpProvider     = PeekL(*Buffer+j+28) 
        AddElement(ListNETRESOURCE())
        Select tempnr\dwScope
          Case #RESOURCE_CONNECTED 
            ListNETRESOURCE()\Scope = "#RESOURCE_CONNECTED"
          Case #RESOURCE_GLOBALNET 
            ListNETRESOURCE()\Scope = "#RESOURCE_GLOBALNET"
          Case #RESOURCE_REMEMBERED 
            ListNETRESOURCE()\Scope = "#RESOURCE_REMEMBERED"
          Default 
            ListNETRESOURCE()\Scope = "dwScope unknown"
        EndSelect
        Select tempnr\dwType
          Case #RESOURCETYPE_ANY 
            ListNETRESOURCE()\Type = "#RESOURCETYPE_ANY"
          Case #RESOURCETYPE_DISK 
            ListNETRESOURCE()\Type = "#RESOURCETYPE_DISK"
          Case #RESOURCETYPE_PRINT 
            ListNETRESOURCE()\Type = "#RESOURCETYPE_PRINT"
          Default 
            ListNETRESOURCE()\Type = "dwType unknown"
        EndSelect 
        Select tempnr\dwDisplayType
          Case #RESOURCEDISPLAYTYPE_DOMAIN 
            ListNETRESOURCE()\DisplayType = "#RESOURCEDISPLAYTYPE_DOMAIN"
          Case #RESOURCEDISPLAYTYPE_GENERIC 
            ListNETRESOURCE()\DisplayType = "#RESOURCEDISPLAYTYPE_GENERIC"
          Case #RESOURCEDISPLAYTYPE_SERVER 
            ListNETRESOURCE()\DisplayType = "#RESOURCEDISPLAYTYPE_SERVER"
          Case #RESOURCEDISPLAYTYPE_SHARE 
            ListNETRESOURCE()\DisplayType = "#RESOURCEDISPLAYTYPE_SHARE"
          Default 
            ListNETRESOURCE()\DisplayType = "dwDisplayType unknown"
        EndSelect 
        Select tempnr\dwUsage
          Case #RESOURCEUSAGE_CONNECTABLE 
            ListNETRESOURCE()\Usage = "#RESOURCEUSAGE_CONNECTABLE"
          Case #RESOURCEUSAGE_CONTAINER 
            ListNETRESOURCE()\Usage = "#RESOURCEUSAGE_CONTAINER"
          Default 
            ListNETRESOURCE()\Usage = "dwUsage unknown"
        EndSelect
        If tempnr\lpLocalName
            ListNETRESOURCE()\LocalName = PeekS(tempnr\lpLocalName) 
          Else 
            ListNETRESOURCE()\LocalName = "" 
        EndIf 
        If tempnr\lpRemoteName
            ListNETRESOURCE()\RemoteName = PeekS(tempnr\lpRemoteName) 
          Else 
            ListNETRESOURCE()\RemoteName = "" 
        EndIf 
        If tempnr\lpComment
            ListNETRESOURCE()\Comment = PeekS(tempnr\lpComment) 
        Else
            ListNETRESOURCE()\Comment = ""
        EndIf 
        If tempnr\lpProvider
            ListNETRESOURCE()\Provider = PeekS(tempnr\lpProvider) 
        Else
            ListNETRESOURCE()\Provider = ""
        EndIf 
        If (tempnr\dwUsage And #RESOURCEUSAGE_CONTAINER) 
          EnumAll (tempnr) 
        EndIf 
      Next 
      WNetCloseEnum_(hEnum)
      FreeMemory(*Buffer)
  EndIf 
EndProcedure 

; 
; Main starts here 
; 
  EnumAll(#NULL)
  
  Quit = #FALSE 
  WindowXSize = 800 
  WindowYSize = 320 
  If OpenWindow(#Window_Main, 0, 0, WindowXSize, WindowYSize, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered, "MyWindow") 
      AddKeyboardShortcut(0, #PB_Shortcut_Escape, #PB_Shortcut_Escape) 
      If CreateGadgetList(WindowID()) 
          SetGadgetFont(#PB_Default, LoadFont(0, "Verdana", 7)) 
          ListIconGadget(#Gadget_ListIcon, 10, 10, WindowXSize - 20, WindowYSize - 20, "Local name", 120, #PB_ListIcon_GridLines | #PB_ListIcon_FullRowSelect) 
          AddGadgetColumn(#Gadget_ListIcon, 1, "Remote name", 120) 
          AddGadgetColumn(#Gadget_ListIcon, 2, "Scope", 120) 
          AddGadgetColumn(#Gadget_ListIcon, 3, "Type", 120) 
          AddGadgetColumn(#Gadget_ListIcon, 4, "Display type", 120) 
          AddGadgetColumn(#Gadget_ListIcon, 5, "Usage", 120) 
          AddGadgetColumn(#Gadget_ListIcon, 7, "Comment", 120) 
          AddGadgetColumn(#Gadget_ListIcon, 8, "Provider", 120) 
          FirstElement(ListNETRESOURCE())
          Repeat
            s.s = ListNETRESOURCE()\Scope + Chr(10)
            s   + ListNETRESOURCE()\Type + Chr(10)
            s   + ListNETRESOURCE()\DisplayType + Chr(10)
            s   + ListNETRESOURCE()\Usage + Chr(10)
            s   + ListNETRESOURCE()\LocalName + Chr(10)
            s   + ListNETRESOURCE()\RemoteName + Chr(10)
            s   + ListNETRESOURCE()\Comment + Chr(10)
            s   + ListNETRESOURCE()\Provider + Chr(10)
            AddGadgetItem(#Gadget_ListIcon,-1,s)
          Until NextElement(ListNETRESOURCE())=0
      EndIf 
       
      Repeat 
        Select WaitWindowEvent() 
          Case #PB_Event_CloseWindow 
            Quit = #TRUE 
          Case #PB_Event_Menu 
            Select EventMenuID() 
              Case #PB_Shortcut_Escape 
                Quit = #TRUE 
            EndSelect 
          Case #PB_EventGadget 
            Select EventGadgetID() 
            EndSelect 
          Case #WM_SIZE 
            WindowXsize = WindowWidth() 
            WindowYSize = WindowHeight() 
            ResizeGadget(#Gadget_ListIcon, 10, 10, WindowXSize - 20, WindowYSize - 20) 
          Default 
        EndSelect 
      Until Quit 
  EndIf 
End 
[/url]

Posted: Sun May 09, 2004 7:52 pm
by ABBKlaus
fweil i tried with disabled ethernet protocols and after reboot i get at least 4 entries :
  • Microsoft-Terminalservice
    Microsoft Windows-Network
    \\SUPERFAST (my PC)
    Web Client Network
Buffer and why the Powerbasic stuff did work :
i think Purebasic handles the array a bit different.
In Powerbasic it works with an array of 8192 Bytes (32 * 256) but i can´t tell why Purebasic doesn´t, anyone can tell us is welcome :?:
Don´t forget the strings are placed at the end of the buffer ! That means the POWERBASIC array is partially filled with the string buffers. Just insert the following code and look for yourself :

Code: Select all

      ec = WNetEnumResource_(hEnum, @Entries, *Buffer, @nSize)
      CreateFile(1,"test.bin")
      WriteData(*Buffer,nSize)
      CloseFile(1)
      For x = 1 To Entries 
BTW i will post this again in Tricks 'n' Tips again under the right topic.
viewtopic.php?t=10817

Hello, all worked ! !

Posted: Mon May 10, 2004 9:34 pm
by DominiqueB
Thank's to both of you that helped me with the ListEnumNetworkRessources prog.
I've been able to make it works the way i whanted and it now returns a list of PC's name separated by Tab.

I've been able to replace my old code that used to use the Net View dos command, now i use the dll i've made for that function too.

Thank's again.

ps: the result is the same as shown before in the fread so i don't post anything more, but it works.

Posted: Tue Aug 23, 2005 7:23 pm
by Droopy
The First Code from ABBKlaus return this in my debugger
The data area passed to a system call is too small.
RequiredSize : 1
Anywone could solve this / Have the same problem ??

Posted: Wed Aug 24, 2005 1:35 pm
by ABBKlaus
Hi Droopy,

Sorry for the late reply i was busy and my computer at work has a defective Harddrive.

some minor code has changed (never updated this in the example)
line 82:

Code: Select all

        If err=#ERROR_IO_PENDING Or err=0

Posted: Wed Aug 24, 2005 2:41 pm
by Droopy
Thanks the code works now for Ports .

But when i try to change zClassName variable to Cdrom
It return nothing ?

Can you help me cause I want to list :
1394/1394debug/61883/adapter/apmsupport/avc/battery/biometric/
bluetooth/cdrom/computer/decoder/diskdrive/display/ dot4print/enum1394/fdc/gps/hdc/hidclass/image/infrared/
keyboard/legacydriver/media/mediumchanger/mtd/modem/ monitor/mouse/multifunction/multiportserial/net/netclient/ netservice/nettrans/nodriver/pcmcia/ports/printer/
printer upgrade/processor/pnpprinters/sbp2/scsiadapter/ security accelerator/smartcardreader/sound/system/tapedrive/ unknown/usb/volume/volumesnapshot/wceusbs

Posted: Wed Aug 24, 2005 8:14 pm
by ABBKlaus
@droopy,

try this code :

Code: Select all

#ClassName=001
#GuidTxt=002
#Friendly=003
#DevDesc=004
#DevDriver=005
#PortName=006

#ERROR_INSUFFICIENT_BUFFER=122
#ERROR_NO_MORE_ITEMS=259
#ERROR_IO_PENDING=997

#DIGCF_DEFAULT=001
#DIGCF_PRESENT=002
#DIGCF_ALLCLASSES=004
#DIGCF_PROFILE=008
#DIGCF_DEVICEINTERFACE=016
#SPDRP_DEVICEDESC=0

#MAX_CLASS_NAME_LEN=128

#DIREG_DEV                         = 001
#DIREG_DRV                         = 002

#DICS_FLAG_GLOBAL                  = 001
#DICS_FLAG_CONFIGSPECIFIC          = 002

#SPDRP_DEVICEDESC                  = 000 ; ECP-Druckeranschluss
#SPDRP_HARDWAREID                  = 001 ; ACPI\PNP0401
#SPDRP_COMPATIBLEIDS               = 002 ; (err13)
#SPDRP_SERVICE                     = 004 ; Parport
#SPDRP_CLASS                       = 007 ; Ports
#SPDRP_CLASSGUID                   = 008 ; {4D36E978-E325-11CE-BFC1-08002BE10318}
#SPDRP_DRIVER                      = 009 ; {4D36E978-E325-11CE-BFC1-08002BE10318}\0000
#SPDRP_CONFIGFLAGS                 = 010 ; 127 (Zahl=Long)
#SPDRP_MFG                         = 011 ; (Standardanschlusstypen)
#SPDRP_FRIENDLYNAME                = 012 ; ECP-Druckeranschluss (LPT1)
#SPDRP_LOCATION_INFORMATION        = 013 ; (err13)
#SPDRP_PHYSICAL_DEVICE_OBJECT_NAME = 014 ; \Device\0000005c
#SPDRP_CAPABILITIES                = 015 ; 48 (Zahl=Long)
#SPDRP_UI_NUMBER                   = 016 ; (err13)
#SPDRP_UPPERFILTERS                = 017 ; (err13)
#SPDRP_LOWERFILTERS                = 018
#SPDRP_BUSTYPEGUID                 = 019
#SPDRP_LEGACYBUSTYPE               = 020
#SPDRP_BUSNUMBER                   = 021
#SPDRP_ENUMERATOR_NAME             = 022 ; ACPI
#SPDRP_SECURITY                    = 023
#SPDRP_SECURITY_SDS                = 024
#SPDRP_DEVTYPE                     = 025
#SPDRP_EXCLUSIVE                   = 026
#SPDRP_CHARACTERISTICS             = 027
#SPDRP_ADDRESS                     = 028
#SPDRP_UI_NUMBER_DESC_FORMAT       = 030

Declare.s GuidTxt()

Structure GUIDAPI
  Data1.l    ; +0
  Data2.w    ; +4
  Data3.w    ; +6
  Data4.b[8] ; +8 = 16
EndStructure

Structure SP_CLASSIMAGELIST_DATA
  cbSize.l
  hImageList.l
  Reserved.l
EndStructure

Structure SP_DEVINFO_DATA
  cbSize.l
  ClassGuid.GUIDAPI
  DevInst.l
  Reserved.l
EndStructure

Structure SP_DEVICE_INTERFACE_DATA
  cbSize.l
  InterfaceClassGuid.GUIDAPI
  Flags.l
  Reserved.l
EndStructure

Structure SP_DEVICE_INTERFACE_DETAIL_DATA
  cbSize.l
  DevicePath.b[128]
EndStructure

Structure InfoArrayStructure
  *Next.Element
  *Previous.Element
  ClassName.s
  GuidTxt.s
  Friendly.s
  DevDesc.s
  DevDriver.s
  PortName.s
EndStructure

zClassName.s="cdrom"
DevName.s=""
PortName.s=""
DevDesc.s=""
DevDriver.s=""
DeviceInterfaceData.SP_DEVICE_INTERFACE_DATA
DeviceInfoData.SP_DEVINFO_DATA
hDeviceInfoSet.l=0
RequiredSize.l=0
hKeyDevice.l=0
HwProfile.l=0
PropertyRegDataType.l=0
DevCount.l=0
Retval.l=0
DeviceCount.l=0
Counter.l=0
Retval=SetupDiClassGuidsFromName_(zClassName,0,0,@RequiredSize)
If Retval=0
  err=GetLastError_()
  Debug "SetupDiClassGuidsFromName Error : "+Str(err)
  Debug "RequiredSize : "+Str(RequiredSize)
EndIf

If RequiredSize
  Dim GuidArray.GUIDAPI(RequiredSize)
  Retval=SetupDiClassGuidsFromName_(zClassName,@GuidArray(1),SizeOf(GUIDAPI)*RequiredSize,@RequiredSize)
  If Retval=0
    err=GetLastError_()
    Debug "SetupDiClassGuidsFromName Error :"+Str(err)
  EndIf
EndIf
hDeviceInfoSet=SetupDiGetClassDevs_(@GuidArray(1),0,0,#DIGCF_PRESENT)
err=GetLastError_()
If err=#ERROR_IO_PENDING
  Debug "Overlapped I/O operation is in progress."
Else
  Debug "Error :"+Str(err)+" : "+Str(hDeviceInfoSet)
EndIf

If hDeviceInfoSet=#INVALID_HANDLE_VALUE
  Debug "Invalid Handle"
EndIf

DeviceInfoData\cbSize=SizeOf(DeviceInfoData)
DeviceInterfaceData\cbSize=SizeOf(DeviceInterfaceData)

NewList InfoArray.InfoArrayStructure()

Repeat

  Retval=SetupDiEnumDeviceInfo_(hDeviceInfoSet,DevCount,@DeviceInfoData)
  If Retval = 0
    err=GetLastError_()
    If err=#ERROR_NO_MORE_ITEMS
      Debug "No more data is available."
    EndIf
    Debug "Exit last device : "+Str(Retval)
    Break
  EndIf
  
  AddElement(InfoArray())
  InfoArray()\ClassName=zClassName
  InfoArray()\GuidTxt=GuidTxt()
  
  DevName=Space(128)
  Retval=SetupDiGetDeviceRegistryProperty_(hDeviceInfoSet,@DeviceInfoData,#SPDRP_FRIENDLYNAME,@PropertyRegDataType,@DevName,Len(DevName),@RequiredSize)
  err=GetLastError_()
  If err=#ERROR_INSUFFICIENT_BUFFER
    Debug "The data area passed to a system call is too small."
  EndIf
  
  Debug "Name: "+DevName
  
  AddElement(InfoArray())
  InfoArray()\Friendly=DevName
  
  DevDesc=Space(128)
  Retval=SetupDiGetDeviceRegistryProperty_(hDeviceInfoSet,@DeviceInfoData,#SPDRP_DEVICEDESC,@PropertyRegDataType,@DevDesc,Len(DevDesc),@RequiredSize)
  err=GetLastError_()
  If err
    Debug "SetupDiGetDeviceRegistryProperty Error : "+Str(err)
  EndIf
  
  Debug "Desc: "+DevDesc
  
  AddElement(InfoArray())
  InfoArray()\DevDesc=DevDesc
  
  DevDriver=Space(128)
  Retval=SetupDiGetDeviceRegistryProperty_(hDeviceInfoSet,@DeviceInfoData,#SPDRP_DRIVER,@PropertyRegDataType,@DevDriver,Len(DevDriver),@RequiredSize)
  err=GetLastError_()
  If err
    Debug "SetupDiGetDeviceRegistryProperty Error : "+Str(err)
  EndIf
  
  Debug "Driver: "+DevDriver
  
  AddElement(InfoArray())
  InfoArray()\DevDriver=DevDriver
  
  hKeyDevice=SetupDiOpenDevRegKey_(hDeviceInfoSet,@DeviceInfoData,#DICS_FLAG_GLOBAL,@HwProfile,#DIREG_DEV,#KEY_QUERY_VALUE)
  err=GetLastError_()
  If err
    Debug "SetupDiOpenDevRegKey Error : "+Str(err)
  EndIf

  PortName=Space(128)
  lpValueName.s="portname"
  lpcbData.l=Len(lpValueName)
  Retval=RegQueryValueEx_(hKeyDevice,@lpValueName,0,0,@PortName,@lpcbData)
  err=GetLastError_()
  If err
    Debug "RegQueryValueEx Error : "+Str(err)
  EndIf
  
  Debug PortName
  
  AddElement(InfoArray())
  InfoArray()\PortName=PortName
  
  RegCloseKey_(hKeyDevice)
  err=GetLastError_()
  If err
    Debug "RegCloseKey Error : "+Str(err)
  EndIf
 
  DevCount+1
ForEver

If hDeviceInfoSet
  SetupDiDestroyDeviceInfoList_(hDeviceInfoSet)
  err=GetLastError_()
  If err
    Debug "SetupDiDestroyDeviceInfoList Error : "+Str(err)
  EndIf
  hDeviceInfoSet=0
EndIf

FirstElement(InfoArray())
Repeat
  Debug InfoArray()\ClassName
  Debug InfoArray()\GuidTxt
  Debug InfoArray()\Friendly
  Debug InfoArray()\DevDesc
  Debug InfoArray()\DevDriver
  Debug InfoArray()\PortName
Until NextElement(InfoArray())=0

Procedure.s GuidTxt()
  Guid$="{" ; {4D36E978-E325-11CE-BFC1-08002BE10318}
  Guid$+    Right("00000000"+Hex(PeekL(@GuidArray(1)\Data1  )),8)
  Guid$+"-"+Right(    "0000"+Hex(PeekW(@GuidArray(1)\Data2  )),4)
  Guid$+"-"+Right(    "0000"+Hex(PeekW(@GuidArray(1)\Data3  )),4)
  Guid$+"-"+Right("00000000"+Hex(PeekL(@GuidArray(1)\Data4  )),8)
  Guid$+    Right("00000000"+Hex(PeekL(@GuidArray(1)\Data4+4)),8)
  Guid$+"}"
  ProcedureReturn Guid$
EndProcedure

Posted: Wed Aug 24, 2005 9:24 pm
by Droopy
Thanks a lot :D :D

Posted: Tue Nov 21, 2006 7:12 am
by Tranquil
ABBKlaus wrote:is i mentioned above the Buffer is essential !!!
without the Buffer you get error number 487 = ERROR_INVALID_ADDRESS

for information see the MSDN at http://msdn.microsoft.com/library/defau ... ources.asp

have fun with this :

Code: Select all

; '============================================================================== 
; '  Network Resource List. 
; '  Enumerate all of the networks and network resources available to the 
; '  current machine. 
; ' converted using http://www.powerbasic.com/support/forums/Forum6/HTML/001494.html 
; '============================================================================== 
#Window_Main = 0 
#Gadget_ListIcon = 0 

Structure NEWNETRESOURCE
  Scope.s
  Type.s
  DisplayType.s
  Usage.s
  LocalName.s
  RemoteName.s
  Comment.s
  Provider.s
EndStructure

NewList ListNETRESOURCE.NEWNETRESOURCE()

Procedure EnumAll(*nr.NETRESOURCE) 
  tempnr.NETRESOURCE
  j.l
  x.l
  Entries = -1 
  nSize = 16384
  *Buffer=AllocateMemory(nSize) 
  ec = WNetOpenEnum_(#RESOURCE_GLOBALNET, #RESOURCETYPE_ANY, #NULL, *nr, @hEnum) 
  If hEnum 
      ec = WNetEnumResource_(hEnum, @Entries, *Buffer, @nSize) 
      For x = 1 To Entries 
        j = (x-1) * SizeOf(NETRESOURCE)
        tempnr\dwScope        = PeekL(*Buffer+j+0) 
        tempnr\dwType         = PeekL(*Buffer+j+4) 
        tempnr\dwDisplayType  = PeekL(*Buffer+j+8) 
        tempnr\dwUsage        = PeekL(*Buffer+j+12) 
        tempnr\lpLocalName    = PeekL(*Buffer+j+16) 
        tempnr\lpRemoteName   = PeekL(*Buffer+j+20) 
        tempnr\lpComment      = PeekL(*Buffer+j+24) 
        tempnr\lpProvider     = PeekL(*Buffer+j+28) 
        AddElement(ListNETRESOURCE())
        Select tempnr\dwScope
          Case #RESOURCE_CONNECTED 
            ListNETRESOURCE()\Scope = "#RESOURCE_CONNECTED"
          Case #RESOURCE_GLOBALNET 
            ListNETRESOURCE()\Scope = "#RESOURCE_GLOBALNET"
          Case #RESOURCE_REMEMBERED 
            ListNETRESOURCE()\Scope = "#RESOURCE_REMEMBERED"
          Default 
            ListNETRESOURCE()\Scope = "dwScope unknown"
        EndSelect
        Select tempnr\dwType
          Case #RESOURCETYPE_ANY 
            ListNETRESOURCE()\Type = "#RESOURCETYPE_ANY"
          Case #RESOURCETYPE_DISK 
            ListNETRESOURCE()\Type = "#RESOURCETYPE_DISK"
          Case #RESOURCETYPE_PRINT 
            ListNETRESOURCE()\Type = "#RESOURCETYPE_PRINT"
          Default 
            ListNETRESOURCE()\Type = "dwType unknown"
        EndSelect 
        Select tempnr\dwDisplayType
          Case #RESOURCEDISPLAYTYPE_DOMAIN 
            ListNETRESOURCE()\DisplayType = "#RESOURCEDISPLAYTYPE_DOMAIN"
          Case #RESOURCEDISPLAYTYPE_GENERIC 
            ListNETRESOURCE()\DisplayType = "#RESOURCEDISPLAYTYPE_GENERIC"
          Case #RESOURCEDISPLAYTYPE_SERVER 
            ListNETRESOURCE()\DisplayType = "#RESOURCEDISPLAYTYPE_SERVER"
          Case #RESOURCEDISPLAYTYPE_SHARE 
            ListNETRESOURCE()\DisplayType = "#RESOURCEDISPLAYTYPE_SHARE"
          Default 
            ListNETRESOURCE()\DisplayType = "dwDisplayType unknown"
        EndSelect 
        Select tempnr\dwUsage
          Case #RESOURCEUSAGE_CONNECTABLE 
            ListNETRESOURCE()\Usage = "#RESOURCEUSAGE_CONNECTABLE"
          Case #RESOURCEUSAGE_CONTAINER 
            ListNETRESOURCE()\Usage = "#RESOURCEUSAGE_CONTAINER"
          Default 
            ListNETRESOURCE()\Usage = "dwUsage unknown"
        EndSelect
        If tempnr\lpLocalName
            ListNETRESOURCE()\LocalName = PeekS(tempnr\lpLocalName) 
          Else 
            ListNETRESOURCE()\LocalName = "" 
        EndIf 
        If tempnr\lpRemoteName
            ListNETRESOURCE()\RemoteName = PeekS(tempnr\lpRemoteName) 
          Else 
            ListNETRESOURCE()\RemoteName = "" 
        EndIf 
        If tempnr\lpComment
            ListNETRESOURCE()\Comment = PeekS(tempnr\lpComment) 
        Else
            ListNETRESOURCE()\Comment = ""
        EndIf 
        If tempnr\lpProvider
            ListNETRESOURCE()\Provider = PeekS(tempnr\lpProvider) 
        Else
            ListNETRESOURCE()\Provider = ""
        EndIf 
        If (tempnr\dwUsage And #RESOURCEUSAGE_CONTAINER) 
          EnumAll (tempnr) 
        EndIf 
      Next 
      WNetCloseEnum_(hEnum)
      FreeMemory(*Buffer)
  EndIf 
EndProcedure 

; 
; Main starts here 
; 
  EnumAll(#NULL)
  
  Quit = #FALSE 
  WindowXSize = 800 
  WindowYSize = 320 
  If OpenWindow(#Window_Main, 0, 0, WindowXSize, WindowYSize, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered, "MyWindow") 
      AddKeyboardShortcut(0, #PB_Shortcut_Escape, #PB_Shortcut_Escape) 
      If CreateGadgetList(WindowID()) 
          SetGadgetFont(#PB_Default, LoadFont(0, "Verdana", 7)) 
          ListIconGadget(#Gadget_ListIcon, 10, 10, WindowXSize - 20, WindowYSize - 20, "Local name", 120, #PB_ListIcon_GridLines | #PB_ListIcon_FullRowSelect) 
          AddGadgetColumn(#Gadget_ListIcon, 1, "Remote name", 120) 
          AddGadgetColumn(#Gadget_ListIcon, 2, "Scope", 120) 
          AddGadgetColumn(#Gadget_ListIcon, 3, "Type", 120) 
          AddGadgetColumn(#Gadget_ListIcon, 4, "Display type", 120) 
          AddGadgetColumn(#Gadget_ListIcon, 5, "Usage", 120) 
          AddGadgetColumn(#Gadget_ListIcon, 7, "Comment", 120) 
          AddGadgetColumn(#Gadget_ListIcon, 8, "Provider", 120) 
          FirstElement(ListNETRESOURCE())
          Repeat
            s.s = ListNETRESOURCE()\Scope + Chr(10)
            s   + ListNETRESOURCE()\Type + Chr(10)
            s   + ListNETRESOURCE()\DisplayType + Chr(10)
            s   + ListNETRESOURCE()\Usage + Chr(10)
            s   + ListNETRESOURCE()\LocalName + Chr(10)
            s   + ListNETRESOURCE()\RemoteName + Chr(10)
            s   + ListNETRESOURCE()\Comment + Chr(10)
            s   + ListNETRESOURCE()\Provider + Chr(10)
            AddGadgetItem(#Gadget_ListIcon,-1,s)
          Until NextElement(ListNETRESOURCE())=0
      EndIf 
       
      Repeat 
        Select WaitWindowEvent() 
          Case #PB_Event_CloseWindow 
            Quit = #TRUE 
          Case #PB_Event_Menu 
            Select EventMenuID() 
              Case #PB_Shortcut_Escape 
                Quit = #TRUE 
            EndSelect 
          Case #PB_EventGadget 
            Select EventGadgetID() 
            EndSelect 
          Case #WM_SIZE 
            WindowXsize = WindowWidth() 
            WindowYSize = WindowHeight() 
            ResizeGadget(#Gadget_ListIcon, 10, 10, WindowXSize - 20, WindowYSize - 20) 
          Default 
        EndSelect 
      Until Quit 
  EndIf 
End 
[/url]
I tried this code at work. (many Networks and many PCs connected) Then the above code do not work correctly. After the procedure found the first network it hangs on WNetOpenEnum_() for about 20-30 seconds and then proceed to the second network. At home with my small LAN, it works fine.