asp.net methods for obtaining Mac values for local and other computers
Source: Internet
Author: User
asp.net 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
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service