Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Network Browser Control Like Explorer
 

Network Browser Control Like Explorer

I am trying to get the list of computers seen by the My Network Places explorer window.  (I am trying to make a custom Explorer-type control) So far, I have the following code snippet.  However, this grabs all the computers that were ever connected to the domain.  I want only those which are currently connected.  Any suggestions?

Public Sub ListDomains()
        Try
            Dim oDomains As New DirectoryEntry("WinNT://MyDomain")
            Dim oDomain As DirectoryEntry
            oDomains.Children.SchemaFilter.Add("Computer")
            For Each oDomain In oDomains.Children
                lstView.Items.Add(oDomain.Name)
            Next
        Catch ex As Exception
            MsgBox("ListDomains: " & ex.Message)
            Exit Sub
        End Try
End Sub
MigrationUser 1  Monday, January 26, 2004 1:58 PM
Well, seeing as I haven't gotten a response yet, I figured I'd let everyone know my temporary solution.  (Seems like a bad one to me).  I'm going to start a thread pool which will ping each computer listed in active directory and display the ones that don't time out.  This seems bad to me, because I'm certain that Microsoft has some way of knowing which computers are actively connected.  I'm also certain that this information is accessible to me programmatically.  I just don't know how as of yet.  Hence the unnecessary pings.  When I'm done with the control I'll see about posting it to this site.

Lata,
CD
MigrationUser 1  Wednesday, January 28, 2004 9:46 AM
This might help

http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=1871&lngWId=10

or

http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=842&lngWId=10

or

http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=1995&lngWId=10
MigrationUser 1  Wednesday, January 28, 2004 1:05 PM
Hey.  Thanks for the reply.  The links are great.  WNetOpenEnum and related functions is basically what I am looking for.  I was hoping for a pure .NET implementation, to ensure compatibility with Longhorn.  But beggars can't be choosers.

CD
MigrationUser 1  Thursday, January 29, 2004 10:53 AM
Longhorn is probably going to wrap this in a managed class for use in .net. 

So who knows.
MigrationUser 1  Thursday, January 29, 2004 12:21 PM
try this, I found it in NetSend application (I don't remember where I downloaded)

'lvwMachineNames: ListView Control

Private Sub GetMachineNames()
        lvwMachineNames.Clear()
        Dim myProcess As Process = New Process
        Dim s As String
        myProcess.StartInfo.FileName = "cmd.exe"
        myProcess.StartInfo.UseShellExecute = False
        myProcess.StartInfo.CreateNoWindow = True
        myProcess.StartInfo.RedirectStandardInput = True
        myProcess.StartInfo.RedirectStandardOutput = True
        myProcess.StartInfo.RedirectStandardError = True
        myProcess.Start()
        Dim sIn As StreamWriter = myProcess.StandardInput
        sIn.AutoFlush = True

        Dim sOut As StreamReader = myProcess.StandardOutput
        Dim sErr As StreamReader = myProcess.StandardError


        sIn.Write("net view" & System.Environment.NewLine)
        sIn.Write("exit" & System.Environment.NewLine)
        s = sOut.ReadToEnd

        If Not myProcess.HasExited Then
            myProcess.Kill()
        End If
        sIn.Close()
        sOut.Close()
        sErr.Close()
        myProcess.Close()
        Dim strarray() As String = s.Split(ControlChars.CrLf)
        Dim strarry1 As String
        Dim finalstr As String
        For Each strarry1 In strarray
            If strarry1.IndexOf("\\") <> -1 Then
                finalstr = strarry1.Remove(1, 2)
                lvwMachineNames.Items.Add(finalstr.Trim())
            End If

        Next
    End Sub
MigrationUser 1  Saturday, April 17, 2004 12:34 AM

You can use google to search for other answers

Custom Search

More Threads

• ToolStrip Problem
• Glyph and Adorner Assistance
• Not being able to drag and drop
• Which is the best inbuilt reporting tool in Vb.net 2005?
• DataGridView DisplayIndex doesn't keep positions
• Text property in Windows Forms Designer
• Is it possible....?
• how can i insert browser control in MFC?
• Generate code for multiple languages using CodeDom
• Could I build applets with WinForms to run in a Browser?