asp.net 获取win7客户端的mac地址 如题请大侠们帮帮忙 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 private string GetMac() 7 { 8 string MAC = ""; 9 ManagementClass MC = new ManagementClass("Win32_NetworkAdapterConfiguration");10 ManagementObjectCollection MOC = MC.GetInstances();11 foreach (ManagementObject moc in MOC)12 {13 if (moc["IPEnabled"].ToString() == "True")14 {15 MAC = moc["MacAddress"].ToString();16 }17 }18 return MAC;19 }202122 public string GetCustomerMac(string IP) //para IP is the client's IP23 {24 if (IP == "127.0.0.1")25 {26 return GetMac();27 }//"00-04-61-5C-31-52";//00-0F-1F-C6-B2-B3 28 else29 {30 string dirResults = "";31 ProcessStartInfo psi = new ProcessStartInfo();32 Process proc = new Process();33 psi.FileName = "nbtstat";34 psi.RedirectStandardInput = false;35 psi.RedirectStandardOutput = true;36 psi.Arguments = "-A " + IP;37 psi.UseShellExecute = false;38 proc = Process.Start(psi);39 dirResults = proc.StandardOutput.ReadToEnd();40 proc.WaitForExit();41 dirResults = dirResults.Replace("\r", "").Replace("\n", "").Replace("\t", "");42 int i = dirResults.LastIndexOf("=");43 dirResults = dirResults.Substring(i + 2, 17);44 if (dirResults.IndexOf("本地连接") != -1)45 { dirResults = "没有得到mac"; }46 return dirResults;47 }48 } http://topic.csdn.net/u/20081107/23/f94cdc80-1afc-4418-aa99-0da478142af0.html 哎,BS的ActiveX插件获取不了Win7下的mac地址哦 private string GetIp() { string strHostName = System.Net.Dns.GetHostName(); System.Net.IPAddress strAddress = System.Net.Dns.Resolve(strHostName).AddressList[0]; string strUrl = "http://www.ip138.com/ip2city.asp"; //获得IP的网址了 Uri uri = new Uri(strUrl); System.Net.WebRequest wr = System.Net.WebRequest.Create(uri); System.IO.Stream s = wr.GetResponse().GetResponseStream(); System.IO.StreamReader sr = new System.IO.StreamReader(s, System.Text.Encoding.Default); string all = sr.ReadToEnd(); //读取网站的数据 int i = all.IndexOf("[") + 1; string tempip = all.Substring(i, 15); string ip = tempip.Replace("]", "").Replace(" ", "");//找出i return ip; } private string GetMac() { string MAC = ""; ManagementClass MC = new ManagementClass("Win32_NetworkAdapterConfiguration"); ManagementObjectCollection MOC = MC.GetInstances(); foreach (ManagementObject moc in MOC) { if (moc["IPEnabled"].ToString() == "True") { MAC = moc["MacAddress"].ToString(); } } return MAC; } public string GetCustomerMac(string IP) { if (IP == "127.0.0.1") { return GetMac(); } else { 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("\r", "").Replace("\n", "").Replace("\t", ""); int i = dirResults.LastIndexOf("="); dirResults = dirResults.Substring(i + 2, 17); if (dirResults.IndexOf("本地连接") != -1) { dirResults = "没有得到mac"; } return dirResults; } }得不到的。不过还是谢谢了 http://topic.csdn.net/u/20090617/11/8f0432b6-84ee-49da-a55f-86b3d343ab8b.html 怎么又讨论这个问题了!???默认是得不到客户端的Mac地址的, 客户端一些系统信息 网络是不能获取的, 这是最基本的安全问题。除非客户手工修改ie安全性设置,用js吧 我一开始用的就是JS的,都启用了但是得到的mac地址是空的。操作系统是win7 还有没有其他真正有效的代码哦,要支持win7系统。这方面的答案很多,我试了好多种了,其中用ActiveX控件的那种,win7下获取过来的mac地址都是空的,但是在其他操作系统上就能获取到的。 求助啊!! 在windows2000 里运行.net2.0出错 如何获取2006年2月27日后一个星期是几年几月几日呢? 诡异问题 解决 求救````ASP.NET 请问asp.net有哪几种验证方式?应该怎么用? CacheDependency问题疑惑 关于将静态页面 移植到 动态页面(ASP NET)的问题 怎么安装SQL server2008 大家帮我看看,下面的代码有问题,很简单的一个调用WScript,怎么都调试不通过,报错。 DragPanelExtender全屏拖动保存位置问题 怎么利用ajaxpro做一个动态的进度工具?
7 {
8 string MAC = "";
9 ManagementClass MC = new ManagementClass("Win32_NetworkAdapterConfiguration");
10 ManagementObjectCollection MOC = MC.GetInstances();
11 foreach (ManagementObject moc in MOC)
12 {
13 if (moc["IPEnabled"].ToString() == "True")
14 {
15 MAC = moc["MacAddress"].ToString();
16 }
17 }
18 return MAC;
19 }
20
21
22 public string GetCustomerMac(string IP) //para IP is the client's IP
23 {
24 if (IP == "127.0.0.1")
25 {
26 return GetMac();
27 }//"00-04-61-5C-31-52";//00-0F-1F-C6-B2-B3
28 else
29 {
30 string dirResults = "";
31 ProcessStartInfo psi = new ProcessStartInfo();
32 Process proc = new Process();
33 psi.FileName = "nbtstat";
34 psi.RedirectStandardInput = false;
35 psi.RedirectStandardOutput = true;
36 psi.Arguments = "-A " + IP;
37 psi.UseShellExecute = false;
38 proc = Process.Start(psi);
39 dirResults = proc.StandardOutput.ReadToEnd();
40 proc.WaitForExit();
41 dirResults = dirResults.Replace("\r", "").Replace("\n", "").Replace("\t", "");
42 int i = dirResults.LastIndexOf("=");
43 dirResults = dirResults.Substring(i + 2, 17);
44 if (dirResults.IndexOf("本地连接") != -1)
45 { dirResults = "没有得到mac"; }
46 return dirResults;
47 }
48 }
哎,BS的ActiveX插件获取不了Win7下的mac地址哦
{
string strHostName = System.Net.Dns.GetHostName();
System.Net.IPAddress strAddress = System.Net.Dns.Resolve(strHostName).AddressList[0];
string strUrl = "http://www.ip138.com/ip2city.asp"; //获得IP的网址了
Uri uri = new Uri(strUrl);
System.Net.WebRequest wr = System.Net.WebRequest.Create(uri);
System.IO.Stream s = wr.GetResponse().GetResponseStream();
System.IO.StreamReader sr = new System.IO.StreamReader(s, System.Text.Encoding.Default);
string all = sr.ReadToEnd(); //读取网站的数据
int i = all.IndexOf("[") + 1;
string tempip = all.Substring(i, 15);
string ip = tempip.Replace("]", "").Replace(" ", "");//找出i
return ip;
} private string GetMac()
{
string MAC = "";
ManagementClass MC = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection MOC = MC.GetInstances();
foreach (ManagementObject moc in MOC)
{
if (moc["IPEnabled"].ToString() == "True")
{
MAC = moc["MacAddress"].ToString();
}
}
return MAC;
}
public string GetCustomerMac(string IP)
{
if (IP == "127.0.0.1")
{
return GetMac();
}
else
{
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("\r", "").Replace("\n", "").Replace("\t", "");
int i = dirResults.LastIndexOf("=");
dirResults = dirResults.Substring(i + 2, 17);
if (dirResults.IndexOf("本地连接") != -1)
{ dirResults = "没有得到mac"; }
return dirResults;
}
}得不到的。不过还是谢谢了
除非客户手工修改ie安全性设置,用js吧
我一开始用的就是JS的,都启用了
但是得到的mac地址是空的。
操作系统是win7
这方面的答案很多,我试了好多种了,其中用ActiveX控件的那种,win7下获取过来的mac地址都是空的,但是在其他操作系统上就能获取到的。