NO

Author Topic: Question about WNetEnumResource()  (Read 4703 times)

CommonTater

  • Guest
Question about WNetEnumResource()
« on: September 05, 2011, 03:58:37 AM »
I've been playing with enumerating files on a LAN... it's the pretty standard structure of \\server\share\folders\files that you see in the windows network browser.

I am using WNetEnumResources() to index the servers and shares, with no problems...
I can use FindFirstFile() and FindNextFile() to enumerate folders and files inside shares, with no problems.

But a question, if I may... 
Does WNetEnumResources() stop at the share level and cannot be used to enumerate folders and files inside a share... or am I perhaps doing something wrong?




Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 582
    • Homepage
Re: Question about WNetEnumResource()
« Reply #1 on: September 05, 2011, 08:02:53 AM »
Does WNetEnumResources() stop at the share level and cannot be used to enumerate folders and files inside a share... or am I perhaps doing something wrong?
As the name of the function tells us it is only usable to enumerate shares and not deeper.
I think that the description at MSDN makes this clear.
---
Stefan

Proud member of the UltraDefrag Development Team

CommonTater

  • Guest
Re: Question about WNetEnumResource()
« Reply #2 on: September 05, 2011, 02:24:03 PM »
Thanks Stefan...

The explaination at MSDN shows nothing below the share level, but never right out says it only goes that far.   I've done it with the "split" process I described before but always wondered...

Thanks! 

« Last Edit: September 05, 2011, 03:07:36 PM by CommonTater »

Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 582
    • Homepage
Re: Question about WNetEnumResource()
« Reply #3 on: September 05, 2011, 06:11:52 PM »
Only file-shares would allow a deeper level, other share types like printers would not.

Since most file functions allow the use of UNC paths, I really doubt there is a need to duplicate functionality.
---
Stefan

Proud member of the UltraDefrag Development Team

CommonTater

  • Guest
Re: Question about WNetEnumResource()
« Reply #4 on: September 05, 2011, 07:10:09 PM »
Only file-shares would allow a deeper level, other share types like printers would not.

Since most file functions allow the use of UNC paths, I really doubt there is a need to duplicate functionality.

I'm not just enumerating shares... The user needs to start with a server name (eg. \\Main) and take it all the way down to folders inside shares and files inside folders inside shares in a TreeView...  It can get 15 layers deep on a couple of the servers.  (Typically: \\Main\Archive\Music\1960s\Beatles\WhiteAlbum\SideOne\YellowBrickRoad.flac )

WNetEnumResources() gets me the servers and shares but not folders and files... FindFirstFile() and FindNextFile() won't get servers or shares but will get folders and files... This is why I was wondering about WNetEnumResources() stopping at shares... it would be a lot easier for me if it didn't :)

Share types such as printers actually are very easily identifed by the dwType member of the returned struct, so they're simply ignored.  It's now just the matter of how to enum general shares... Especially tricky since there's no native way to tell the difference between a DVD in a shared drive and a folder share on a hard disk... Lots and lots of vetting going on...

I do have this working with the dual methods, but it incurs a fair bit of software overhead figuring things out as the user tunnels in to the files...
« Last Edit: September 05, 2011, 07:23:00 PM by CommonTater »

Offline Bitbeisser

  • Global Moderator
  • Member
  • *****
  • Posts: 772
Re: Question about WNetEnumResource()
« Reply #5 on: September 05, 2011, 09:10:31 PM »
Well, as the function is called "EnumResource" it shows you what resources are available, not their contents.

And as already mentioned, a resource can be more than just shared folders but also printers, scanners, etc.
Those resources simply do not have any uniform contents to report back. That's why to get information below the resource level, you have to use methods unique to that resource type. For folders and files, this is then findfirst/findnext, which of course doesn't make any sense on a networked printer or scanner, there you would have to use a method appropriate for that resource, like retrieving printer capabilities, etc...

Ralf

CommonTater

  • Guest
Re: Question about WNetEnumResource()
« Reply #6 on: September 06, 2011, 02:23:00 AM »
Hi Ralf... Actually since all I'm concerned with right now is files... I think I'll worry about the rest of it another time :) 

I've actually been working to eliminate all non-disk resources from the list in this case.