WNetOpenEnum wont enumerate past the root level (error 1231) RRS feed

  • Question

  • I have written a simple bit of code to enumerate the network structure with the goal of finding all shares available on the network. However my code never gets past the root level and fails when I recursively call the routine on an item set to RESOURCEUSAGE_CONTAINER.

    This is on a Windows 10 system with basic home networking. I can see network devices in explorer without any problems.

    My code is essentially a copy of the example given in MSDN for WNetOpenEnum (link rejected).

    At the root I get: "Microsoft Terminal Services", "Microsoft Windows Network" and "Web Client Network".
    Tracing my code into enumerating the "Microsoft Windows Network" I find that the call to WNetOpenEnum returns ERROR_NETWORK_UNREACHABLE.

    Any ideas why this is not working?

    Thanks in advance,

    Monday, March 25, 2019 11:59 PM

All replies

  • As a sanity check (and possibly a time saver) try this -
    Tuesday, March 26, 2019 10:49 AM
  • Thanks for that. Running that produces an error "No domains or workgroups where found on your network" so I suspect this app is having the same issue I am seeing with my code. 

    If this API cannot see my Workgroup (Using the default "WORKGROUP", its a very simple network) then Explorer must be using something else to do the discovery as that correctly displays shares on the network. Also a standard windows Open File dialog successfully discovers the network. 

    I did discover after posting this that my code works on a Windows 7 machine that I have. 


    Tuesday, March 26, 2019 7:34 PM