转自:
http://www.guoblog.com/blogview.asp?logID=202
PublicFunctionValueSepR(ByValRawStringAsString,ByValSepCharAsString)AsString
IfInStr(1,RawString,SepChar)<>0Then
ValueSepR=Microsoft.VisualBasic.Right(RawString,Len(RawString)-InStr(1,RawString,SepChar))
Else
ValueSepR=RawString
EndIf
EndFunction
PublicFunctionGetMac(ByValIPAsString)AsString
Try
DimdirResultsAsString
DimpsiAsSystem.Diagnostics.ProcessStartInfo=NewSystem.Diagnostics.ProcessStartInfo()
DimprocAsNewSystem.Diagnostics.Process()
psi.FileName="nbtstat"
psi.RedirectStandardInput=False
psi.RedirectStandardOutput=True
psi.Arguments="-A"&IP
psi.UseShellExecute=False
proc=System.Diagnostics.Process.Start(psi)
DimxAsInteger=-1
DoUntilx>-1
IfdirResults<>NothingThen
x=dirResults.Trim.ToLower.IndexOf("macaddress",0)
Ifx>-1Then
ExitDo
EndIf
EndIf
dirResults=proc.StandardOutput.ReadLine
Loop
proc.WaitForExit()
GetMac=ValueSepR(dirResults.Trim,"=").Trim
CatcherrAsException
Response.Write(err.Message&err.StackTrace)
EndTry
EndFunction
PublicFunctionValueSepR(ByValRawStringAsString,ByValSepCharAsString)AsString
IfInStr(1,RawString,SepChar)<>0Then
ValueSepR=Microsoft.VisualBasic.Right(RawString,Len(RawString)-InStr(1,RawString,SepChar))
Else
ValueSepR=RawString
EndIf
EndFunction
PublicFunctionGetMac(ByValIPAsString)AsString
Try
DimdirResultsAsString
DimpsiAsSystem.Diagnostics.ProcessStartInfo=NewSystem.Diagnostics.ProcessStartInfo()
DimprocAsNewSystem.Diagnostics.Process()
psi.FileName="nbtstat"
psi.RedirectStandardInput=False
psi.RedirectStandardOutput=True
psi.Arguments="-A"&IP
psi.UseShellExecute=False
proc=System.Diagnostics.Process.Start(psi)
DimxAsInteger=-1
DoUntilx>-1
IfdirResults<>NothingThen
x=dirResults.Trim.ToLower.IndexOf("macaddress",0)
Ifx>-1Then
ExitDo
EndIf
EndIf
dirResults=proc.StandardOutput.ReadLine
Loop
proc.WaitForExit()
GetMac=ValueSepR(dirResults.Trim,"=").Trim
CatcherrAsException
Response.Write(err.Message&err.StackTrace)
EndTry
EndFunction