Click here to Skip to main content
13,254,187 members (58,725 online)
Click here to Skip to main content
Add your own
alternative version


21 bookmarked
Posted 25 Aug 2002

List Peer Servers and their IP Addresses inside a Workgroup.

Rate this:
Please Sign up or sign in to vote.
How to list the peer servers and IP addresses in the workgroup - A simple approach.

Sample Image - PeerLister.jpg


How can peer servers inside a work group be listed. I wanted to demonstrate a simple method to perform this operation. System.Remoting namespace provides certain APIs using which this can be performed. At CodeProject, I saw a couple of articles performing similar operations in MC++ and they printout the IP addresses too.

The articles are available at these links:


I chose to use the Shell basics. Using Shell basics, several tasks can be done very simply. The Shell32 DLL is interoped with the project and it exposes a number of methods, classes and interfaces to perform a lot of operations, like using the Windows UI.

The Shell organizes these objects into a hierarchical structure called the namespace, which provides users and applications with a consistent and efficient way to access and manage objects. Users interact with the namespace through the Shell's graphical UI or through an application. Applications interact with the namespace through the Shell's application programming interface (API). This section is an introduction to the Shell API.

There are plenty of objects used to create applications and manage the operating system. The most familiar of these objects are the folders and files that reside on computer disk drives and over networks.

Some of the basics ,how-tos and the APIs used will be explained in this article.

The platform considered is Windows 2000 Server and such a server present under a workgroup server. The requirement is to view the peer servers under the workgroup. Shell basics are used to perform the above said task.

Some Preliminaries

The workgroup when opened using an Explorer, displays the servers that are present in it. One has to understand the differences between:

  1. Folder
  2. NameSpace
  3. FolderItem
  4. Link, etc.

An object of type Shell32.Shell is created and another object of type Shell32.Folder is also created. There are some special folders specified. Such as ShellSpecialFolderConstants.ssfNETWORK represents the Network Places folder. My Documents, Control Panel and several special folders are defined and are identified by separate constants.

The folder is parsed only when isFileSystem return false. The link is opened by using Shell.NameSpace(object) and iterated until the workgroup server folder is reached.

Once the namespace is known, the items() gives a collection, from which an individual item can be retrieved. The code is given below:

Shell32.Shell sh = new Shell32.Shell();
Shell32.Folder currFolder = 
int num = 
MessageBox.Show("The Num of Items in special folder in the local",
for(int i=0;i<num;i++)

   int no =sh.NameSpace(currFolder.Items().Item(i)).Items().Count;
   currFolder = sh.NameSpace(currFolder.Items().Item(i));

   MessageBox.Show(currFolder.Items().Item(0).Name+": Cool");
   MessageBox.Show(currFolder.Items().Count+": Count");

   for(int k=1;k<mycount;k++)

     listView1.Items.Add(new ListViewItem

    catch(Exception myexcep)
     MessageBox.Show(myexcep.ToString()+" : Error");



There is a very simple method to find the IP address of the servers under the workgroup server. These are found in the System.Net namespace. The peer servers are added in to a ListView control as listviewItem. The Net Namespace contains a plethora of classes and APIs for network access. The IP address can be found by passing the domain name of the server.

Sample Image - IP Address.jpg

The giveAddress method returns the IP address of the Server.

this.listView1.DoubleClick += new System.EventHandler(this.giveAddress);

The following is an example of how it is done....

private void giveAddress(object sender, System.EventArgs e)

The MessageBox displays the IP address of the selected server.


This is an illustration of the use of the Shell basics and a method for how the peers in a workgroup are listed and the IP addresses of the servers found.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Ragavendran Vaidhyanadhan
Web Developer
United States United States
Ragavendran was born in South India. He holds a Bacnelor of Computer Science and Engineering. Currently he works as a Software Engineer. He is techno Savvy and All he wishes to do in life is to get to know a lotta things....
He is always intrigued about learning new things.

His skills include C,C++,Java ,.NET.He also experience working in Legacy Systems. He feels most comfortable with C++ and Java.
Computers are his first love and he likes reading books, music and trekking.

He is a voracious reader and loves reading books. A Leo by birth, he loves trekking and gardening. One of his main ambitions is to write his autobiography, though he is not sure who will read it.

You may also be interested in...


Comments and Discussions

Generalerrors Pin
Anonymous2-Nov-02 9:13
sussAnonymous2-Nov-02 9:13 
GeneralRe: errors Pin
Ragavendran Vaidhyanadhan1-Apr-03 3:02
memberRagavendran Vaidhyanadhan1-Apr-03 3:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171114.1 | Last Updated 27 Aug 2002
Article Copyright 2002 by Ragavendran Vaidhyanadhan
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid