VB.NET獲取區域網IP和MAC地址
阿新 • • 發佈:2019-02-20
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
For i = 1 To 10
My.Computer.Network.Ping("192.168.1." & i, 5)
Me.ProgressBar1.Value = i / 10 * 100
Application.DoEvents()
Next
Shell("C:\a.bat", AppWinStyle.Hide, True, 1000)
Dim regex As New System.Text.RegularExpressions.Regex("(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}) +(\w\w-\w\w-\w\w-\w\w-\w\w-\w\w)")
Dim mach As System.Text.RegularExpressions.MatchCollection
While True
If My.Computer.FileSystem.FileExists("C:\a.txt") Then
Exit While
End If
End While
Dim tmp As String = My.Computer.FileSystem.ReadAllText("C:\a.txt")
mach = regex.Matches(tmp)
Me.ListView1.Items.Clear()
Dim lsv As ListViewItem
For Each x As System.Text.RegularExpressions.Match In mach
Dim z As System.Text.RegularExpressions.Group
z = x.Groups(1)
lsv = New ListViewItem()
lsv.Text = z.Value
z = x.Groups(2)
lsv.SubItems.Add(z.Value)
Me.ListView1.Items.Add(lsv)
Next
End Sub
For i = 1 To 10
My.Computer.Network.Ping("192.168.1." & i, 5)
Me.ProgressBar1.Value = i / 10 * 100
Application.DoEvents()
Next
Shell("C:\a.bat", AppWinStyle.Hide, True, 1000)
Dim regex As New System.Text.RegularExpressions.Regex("(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}) +(\w\w-\w\w-\w\w-\w\w-\w\w-\w\w)")
Dim mach As System.Text.RegularExpressions.MatchCollection
While True
If My.Computer.FileSystem.FileExists("C:\a.txt") Then
Exit While
End If
End While
Dim tmp As String = My.Computer.FileSystem.ReadAllText("C:\a.txt")
mach = regex.Matches(tmp)
Me.ListView1.Items.Clear()
Dim lsv As ListViewItem
For Each x As System.Text.RegularExpressions.Match In mach
Dim z As System.Text.RegularExpressions.Group
z = x.Groups(1)
lsv = New ListViewItem()
lsv.Text = z.Value
z = x.Groups(2)
lsv.SubItems.Add(z.Value)
Me.ListView1.Items.Add(lsv)
Next
End Sub