日期:2014-05-20 浏览次数:21504 次
<--
这是我之前做的..可以获取到..不过要设置浏览器的允许Activex插件运行
-->
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head >
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<object id="locator" classid="CLSID:76A64158-CB41-11D1-8B02-00600806D9B6" viewastext> </object>
<object id="foo" classid="CLSID:75718C9A-F029-11d1-A1AC-00C04FB6C223"> </object>
<script type="text/jscript" event="OnObjectReady(objObject,objAsyncContext)" for="foo" >
if(objObject.IPEnabled !=null &&objObject.IPEnabled !="undefined"&&objObject.IPEnabled==true)
{
if(objObject.MACAddress!= null&&objObject.MACAddress!="undefined")
MACAddr = objObject.MACAddress;
}
</script>
<script type="text/jscript">
var service = locator.ConnectServer();
var MACAddr ;
service.Security_.ImpersonationLevel=3;
service.InstancesOfAsync(foo, 'Win32_NetworkAdapterConfiguration');
</script>
<script type="text/jscript" event="OnCompleted(hResult,pErrorObject,pAsyncContext)" for="foo" >
document.form1.TextBox1.value=unescape(MACAddr);
document.form1.submit();
</script>
<title>无标题页 </title>
</head>
<body>
<form id="form1" runat="server">
<%aaaa(); %>
<div>
获取网卡地址前,请进入Internet属性设置->安全>自定义级别->"对没有标记为安全的ActiveX控件进行初始化和脚本运行"->点选"启用"
</div>
<div>
您目前的网卡地址是:<asp:TextBox ID="TextBox1" runat="server"> </asp:TextBox>
<asp:Button ID="button1" runat="server" OnClick="button1_Click1" />
</div>
</form>
</body>
</html>
<script runat="server">
protected void aaaa()
{
// http://192.168.0.144/Proscenium/PublicFile/dd.aspx
if (!string.IsNullOrEmpty(this.TextBox1.Text))
{
Session["objObject.MACAddress"] = this.TextBox1.Text;
}
if (Session["objObject.MACAddress"] != null)
{
Response.Redirect("help000.html");
return;
}
}
protected void button1_Click(object sender, EventArgs e)
{
aaaa();
}
protected void button1_Click1(object sender, EventArgs e)
{
aaaa();
}
protected void Page_Load(object sender, EventArgs e)
{
}
</script>