(1)下载ClientInfo.dll(在我的资源中可以下载http://download.csdn.net/source/2141582)
(2)注册库文件:regsvr32 ClientInfo.dll
(3)使用new ActiveXObject("ClientInfo.HostInfo")调用ActiveX库
(4)GetAdapterMac(0)获取网卡MAC地址
使用示例:
<HTML>
<TITLE>ClientInfoX JavaScript Sample</TITLE>
<HEAD>
<script language="JavaScript">
//
//函数与方法
//
function AddInfo(sInf)
{
xo=new ActiveXObject("ClientInfo.HostInfo")
document.getElementById("mbox").value = "/r" +sInf +document.getElementById("mbox").value;
}
function GetWindowsVersion()
{
xo=new ActiveXObject("ClientInfo.HostInfo")
AddInfo("GetWindowsVersion: "+xo.GetWindowsVersion());
//getusername();
}
function GetCPU_ID()
{
xo=new ActiveXObject("ClientInfo.HostInfo")
AddInfo("GetCPU_ID: "+xo.GetCPU_ID());
}
function GetAdapterMac()
{
xo=new ActiveXObject("ClientInfo.HostInfo")
AddInfo("GetNET_ID: "+xo.GetAdapterMac(0));
}
function GetIdeSerialNumber()
{
xo=new ActiveXObject("ClientInfo.HostInfo")
AddInfo("GetIdeSerialNumber: "+xo.GetIdeSerialNumber());
}
function ClearmBox()
{
document.getElementById("mbox").value = "";
}
</script>
</HEAD>
<BODY><center>
<FORM ACTION="#" NAME="forms"><table width="100%" border="1" cellpadding="0" cellspacing="0" onload height="330">
<tr>
<td width="9%" height="30"><center><h3>ClientInfoX.dll 实例 </h3></center></td>
</tr>
<tr>
<td width="9%" height="30"><center>
<p>消息窗口<br>
<textarea name="mbox" cols="80" rows="10">
</textarea>
</p>
</center></td>
</tr>
<tr>
<td width="9%" height="30"><center>
<INPUT TYPE=button VALUE="WindowsVersion" ONCLICK="GetWindowsVersion()" NAME="Button1">
<INPUT TYPE=button VALUE="GetCPU_ID" ONCLICK="GetCPU_ID()" NAME="Button2">
<INPUT TYPE=button VALUE="GetAdapterMac" ONCLICK="GetAdapterMac()" NAME="Button3">
<INPUT TYPE=button VALUE="GetIdeSerialNumber" ONCLICK="GetIdeSerialNumber()" NAME="Button4">
<INPUT TYPE=button VALUE="清除显示" ONCLICK="ClearmBox()" NAME="MsClear">
</center></td>
</tr>
</table>
</FORM>
</center>
</BODY>
</HTML>