Code Snippet posted by:
Initiotech | Posted on: 9/22/2009 | Category:
VB.NET Codes | Views: 1745 | Status:
[Member]
|
Alert Moderator
This code sample is used to get all the names of computers that are there in your network.
You need to Iterate with the Children entries of the Directory Entries.
The Below Sample is in Console Application
Sub Main()
Dim root As New DirectoryEntry("WinNT:")
Dim parent As DirectoryServices.DirectoryEntries
parent = root.Children
Dim d As DirectoryEntries = parent
For Each complist As DirectoryEntry In parent
For Each c As DirectoryEntry In complist.Children
If (c.Name <> "Schema") Then
Console.WriteLine(c.Name)
End If
Next
Next
End Sub
You can use the same code to Add the Names of the Network Computers in a Combobox or a ListBox
For Each c As DirectoryEntry In complist.Children
If (c.Name <> "Schema") Then
ComboBox1.Items.Add(c.Name)
End If
Next
Regards
Hefin Dsouza