正文

Asp.Net获取本地计算机和其他计算机的MAC值的方法2006-05-11 15:33:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/Csharpsky/13895.html

分享到:

Public Function ValueSepR(ByVal RawString As String, ByVal SepChar As String) As String
        If InStr(1, RawString, SepChar) <> 0 Then
            ValueSepR = Microsoft.VisualBasic.Right(RawString,Len(RawString) - InStr(1, RawString, SepChar))
        Else
            ValueSepR = RawString
        End If
End Function
Public Function GetMac(ByVal IP As String) As String
        Try
            Dim dirResults As String
            Dim psi As System.Diagnostics.ProcessStartInfo = New System.Diagnostics.ProcessStartInfo()
            Dim proc As New System.Diagnostics.Process()
            psi.FileName = "nbtstat"
            psi.RedirectStandardInput = False
            psi.RedirectStandardOutput = True
            psi.Arguments = "-A " & IP
            psi.UseShellExecute = False
            proc = System.Diagnostics.Process.Start(psi)
            Dim x As Integer = -1
            Do Until x > -1
                If dirResults <> Nothing Then
                    x = dirResults.Trim.ToLower.IndexOf("mac address", 0)
                    If x > -1 Then
                        Exit Do
                    End If
                End If
                dirResults = proc.StandardOutput.ReadLine
            Loop
            proc.WaitForExit()
            GetMac = ValueSepR(dirResults.Trim, "=").Trim
        Catch err As Exception
            Response.Write(err.Message & err.StackTrace)
        End Try
End Function

阅读(2476) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册