復制代碼 代碼如下:
using System.Text.RegularExpressions;
using System.Diagnostics;
public class test
{
public test
{}
public static string GetCustomerMac(string IP) //para IP is the clients IP
{
string dirResults="";
ProcessStartInfo psi = new ProcessStartInfo();
Process proc = new Process();
psi.FileName = "nbtstat";
psi.RedirectStandardInput = false;
psi.RedirectStandardOutput = true;
psi.Arguments = "-A " + IP;
psi.UseShellExecute = false;
proc = Process.Start(psi);
dirResults = proc.StandardOutput.ReadToEnd();
proc.WaitForExit();
dirResults=dirResults.Replace(" ","").Replace(" ","").Replace(" ","");
Regex reg=new Regex("Mac[ ]{0,}Address[ ]{0,}=[ ]{0,}(?key>((.)*?)) __MAC",RegexOptions.IgnoreCase|RegexOptions.Compiled);
Match mc=reg.Match(dirResults+"__MAC");
if(mc.Success)
{
return mc.Groups["key"].Value;
}
else
{
reg=new Regex("Host not found",RegexOptions.IgnoreCase|RegexOptions.Compiled);
mc=reg.Match(dirResults);
if(mc.Success)
{
return "Host not found!";
}
else
{
return "";
}
}
}
}
您可能感興趣的文章:- ASP.NET簡單獲取服務(wù)端和客戶端計算機名稱的方法
- 獲取asp.net服務(wù)器控件的客戶端ID和Name的實現(xiàn)方法
- asp.net實現(xiàn)獲取客戶端詳細信息
- ASP.net中獲取客戶端參數(shù)操作系統(tǒng)信息
- Asp.net獲取客戶端IP常見代碼存在的偽造IP問題探討
- 獲取客戶端IP地址c#/vb.net各自實現(xiàn)代碼
- ASP.NET獲取真正的客戶端IP地址的6種方法
- jquery獲取ASP.NET服務(wù)器端控件dropdownlist和radiobuttonlist生成客戶端HTML標簽后的value和text值
- .NET獲取客戶端的操作系統(tǒng)版本、瀏覽器版本和IP地址