16,549
社区成员
发帖
与我相关
我的任务
分享
Imports System.Diagnostics
Imports System.Threading
Public Class myThread
Private ip As String
Private cnt As Integer
Public ff As DataGridView
Public Sub setinfo(ByVal tip As String, ByVal tcnt As Integer)
Me.ip = tip
Me.cnt = tcnt
Dim myth As Thread = New Thread(New ThreadStart(AddressOf vs_ipmac))
myth.Start()
End Sub
Private Sub vs_ipmac()
ff.Rows(cnt).Cells(3).Value = "扫描中..."
Dim str1 As String = String.Empty
Try
Dim str2 As String = String.Empty
Dim info1 As ProcessStartInfo = New ProcessStartInfo()
Dim process1 As Process = New Process()
info1.FileName = "nbtstat"
info1.RedirectStandardInput = False
info1.RedirectStandardOutput = True
info1.Arguments = "-A " + ip
info1.UseShellExecute = False
info1.CreateNoWindow = True
process1 = Process.Start(info1)
Dim num1 As Integer = -1
While (num1 <= -1)
num1 = str2.Trim().ToLower().IndexOf("mac address", 0)
If (num1 > -1) Then
Exit While
End If
str2 = process1.StandardOutput.ReadLine()
process1.WaitForExit()
str1 = str2.Trim()
End While
Catch ex As Exception
'Throw ex
End Try
If str1 <> "" Then
If LCase(ff.Rows(cnt).Cells(4).Value.ToString) <> LCase(Right(str1, 17)) Then
ff.Rows(cnt).Cells(2).Value = My.Resources.flag_yellow
Else
ff.Rows(cnt).Cells(2).Value = My.Resources.flag_green
End If
ff.Rows(cnt).Cells(3).Value = Right(str1, 17)
Else
ff.Rows(cnt).Cells(3).Value = "未检测到mac地址"
End If
End Sub
End Class