How to enumerate computers on network

How to enumerate computers on network

Post by Lawrence Grove » Wed, 16 Oct 2002 01:01:15



Hi all,

I am writing some code that needs to enumerate all the computers on my
network. But the problem is that there is more than one domain/workgroup
with computers in. I use SHGetSpecialFolderLocation with a value of
CSIDL_NETWORK as a starting point which gives me entry to the following
hierarchy:

Entire Network
    Microsoft Windows Network
        Domain1
            Computer1
        Workgroup1
            Computer2
    Directory
......

I would have thought that I need to enumerate each domain and workgroup in
turn to give me a complete list. But where is my starting point? I don't
want to check for a specific string that might change in the future like
'Microsoft Windows Network'.

In Explorer, the domain and workgroup are marked with an icon that has three
little computers. Each computer has a different icon. How does Explorer
determine the type of element each thing is so that it can come up with the
right icon? That would appear to be a safer way to get me where I want to
go.... somehow determine the type of each element in the tree.

I am using Windows2000, IE6 SP1 but want to be portable to XP and other
things in the future.

Thanks for any help.

Loz.

 
 
 

How to enumerate computers on network

Post by Jim Barr » Wed, 16 Oct 2002 06:35:01



> In Explorer, the domain and workgroup are marked with an
> icon that has three little computers. Each computer has a
> different icon. How does Explorer determine the type of
> element each thing is so that it can come up with the right
> icon? That would appear to be a safer way to get me where
> I want to go.... somehow determine the type of each element
> in the tree.

SHGetDataFromIDList with the SHGDFIL_DESCRIPTIONID has some ability to
determine the type of an item in the shell namespace. Or you could
forget the shell namespace and go straight to the WNet API.

--
Jim Barry
MVP for Windows SDK

 
 
 

How to enumerate computers on network

Post by Lawrence Grove » Wed, 16 Oct 2002 19:43:05




> > In Explorer, the domain and workgroup are marked with an
> > icon that has three little computers. Each computer has a
> > different icon. How does Explorer determine the type of
> > element each thing is so that it can come up with the right
> > icon? That would appear to be a safer way to get me where
> > I want to go.... somehow determine the type of each element
> > in the tree.

> SHGetDataFromIDList with the SHGDFIL_DESCRIPTIONID has some ability to
> determine the type of an item in the shell namespace. Or you could
> forget the shell namespace and go straight to the WNet API.

Thanks for that Jim. I did it using your first method because I am already
skipping down the shell's namespace using the SH..() API and didn't want to
have to start messing with WNet aswell !!!

Loz.