پیدا کردن ip های شبکه

ms_vb

Member
سلام
چطور توی VB.net میتونم Ip های کل کامپیوتر های شبکه رو پیدا کنم
lممنونم از جوابتون
 

the_king

مدیرکل انجمن
سلام
چطور توی VB.net میتونم Ip های کل کامپیوتر های شبکه رو پیدا کنم
lممنونم از جوابتون

چه نوع شبکه ای؟ فرضا من به عنوان یک کاربر به شبکه ای که سرویس دهنده اینترنتی ام ارائه کرده متصل هستم و قاعدتا نمی توانم یا اجازه ندارم که سایر کاربران سرویس دهنده رو
شناسایی کنم. صرفا می توانم لیست ارتباط هایی که خودم برقرار می کنم (فرضا از یک سایت در حال دانلود فایلی هستم) رو لیست کنم :
کد:
Imports System.Net.NetworkInformation
Imports System.Text

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim ipgProps As IPGlobalProperties
        Dim tcpCons() As TcpConnectionInformation
        Dim s As New StringBuilder
        ipgProps = IPGlobalProperties.GetIPGlobalProperties()
        tcpCons = ipgProps.GetActiveTcpConnections()
        For Each item As TcpConnectionInformation In tcpCons
            s.AppendLine(String.Format("{0}  {1}", item.LocalEndPoint, item.RemoteEndPoint))
        Next
        MessageBox.Show(s.ToString())
    End Sub
End Class
 

the_king

مدیرکل انجمن
ممنونم از جوابتون
منظورم شبکه محلی بود

این ها رو اول کد تون Import کنید :
کد:
Imports System.Text
Imports System.Net
Imports System.IO
Imports System.Diagnostics

و کد زیر رو امتحان کنید :
کد:
        Dim line As String = ""
        Dim s As New StringBuilder
        Dim ip As String
        Dim name As String
        Using netUtility As New Process
            With netUtility.StartInfo
                .FileName = "net.exe"
                .Arguments = "view"
                .CreateNoWindow = True
                .RedirectStandardOutput = True
                .RedirectStandardError = True
                .UseShellExecute = False
            End With
            netUtility.Start()
            Using streamReader As New StreamReader( _
                netUtility.StandardOutput.BaseStream _
                , netUtility.StandardOutput.CurrentEncoding)
                Do
                    line = streamReader.ReadLine()
                    If line Is Nothing Then
                        Exit Do
                    End If
                    If line.StartsWith("\\") Then
                        name = line.Substring(0, line.IndexOf(" ")).Substring(2)
                        ip = ""
                        Try
                            Dim host As IPHostEntry = Dns.GetHostEntry(name)
                            For Each item As IPAddress In host.AddressList
                                If item.AddressFamily = Sockets.AddressFamily.InterNetwork Then
                                    ip = item.ToString()
                                    Exit For
                                End If
                            Next
                        Catch ex As Exception
                        End Try
                        s.AppendLine(String.Format("{0}{1} {2}", name, vbTab, ip))
                    End If
                Loop
            End Using
        End Using
        MessageBox.Show(s.ToString())
 

جدیدترین ارسال ها

بالا