給政府做的,完全要求高,居然用硬盤序列號(hào),MAC地址,CPU地址三項(xiàng)來綁定指定的人來操作。
看了看別的資料有提取CPU,MAC的現(xiàn)成代碼卻沒有硬盤序列號(hào),找了好久才找到提取硬盤序列號(hào)的參數(shù)。于是自己給補(bǔ)上了。
特別說明:以下方法用到了ActiveXObject,只有IE瀏覽器才支持此組件。
<html>
<head>
<title>提取硬盤序列號(hào)</title>
<script>
function disk() {//硬盤序列號(hào) 信息
var locator = new ActiveXObject ("Wbemscripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.execQuery("select * from Win32_DiskDrive");
var e = new Enumerator (properties);
document.write("<table border=1>");
for (;!e.atEnd();e.moveNext ())
{
var p = e.item ();
document.write("<tr>");
document.write("<td>" + p.signature + "</td>");
document.write("</tr>");
}
document.write("</table>");
}
</script>
</head>
<body>
<input type="button" value="硬盤序列號(hào)" onclick="disk()">
</body>
</html>
在這上找的代碼:
對(duì)于寫過ASP或.net 的人來說,通過asp或.net 語言來獲得客戶端的硬件信息是很熟悉的.但如何通過javascript這種客戶端腳本來獲得客戶端的信息呢?請(qǐng)看以下實(shí)例:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>javascript獲得客戶端硬件信息-www.web2bar.cn/</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET
7.1">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<script id=clientEventHandlersJS language=javascript>
<!--
function Button2_onclick() {//CPU 信息
var locator = new ActiveXObject ("Wbemscripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.execQuery("select * from Win32_Processor");
var e = new Enumerator (properties);
document.write("<table border=1>");
for (;!e.atEnd();e.moveNext ())
{
var p = e.item ();
document.write("<tr>");
document.write("<td>" + p.Caption + "</td>");
document.write("<td>" + p.DeviceID + "</td>");
document.write("<td>" + p.Name + "</td>");
document.write("<td>" + p.CpuStatus + "</td>");
document.write("<td>" + p.Availability + "</td>");
document.write("<td>" + p.Level + "</td>");
document.write("<td>" + p.ProcessorID + "</td>");
document.write("<td>" + p.SystemName + "</td>");
document.write("<td>" + p.ProcessorType + "</td>");
document.write("</tr>");
}
document.write("</table>");
}
function Button1_onclick() {//軟盤信息
var locator = new ActiveXObject ("Wbemscripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.execQuery("select * from Win32_FloppyDrive");
var e = new Enumerator (properties);
document.write("<table border=1>");
for (;!e.atEnd();e.moveNext ())
{
var p = e.item ();
document.write("<tr>");
document.write("<td>" + p.Description + "</td>");
document.write("<td>" + p.DeviceID + "</td>");
document.write("<td>" + p.Status + "</td>");
document.write("<td>" + p.Manufacuturer + "</td>");
document.write("</tr>");
}
document.write("</table>");
}
function Button1_onclick() {//CD-ROM 信息
var locator = new ActiveXObject ("Wbemscripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.execQuery("select * from Win32_CDROMDrive");
var e = new Enumerator (properties);
document.write("<table border=1>");
for (;!e.atEnd();e.moveNext ())
{
var p = e.item ();
document.write("<tr>");
document.write("<td>" + p.Caption + "</td>");
document.write("<td>" + p.Description + "</td>");
document.write("<td>" + p.Drive + "</td>");
document.write("<td>" + p.Status + "</td>");
document.write("<td>" + p.MediaLoaded + "</td>");
document.write("</tr>");
}
document.write("</table>");
}
function Button1_onclick() {//鍵盤信息
var locator = new ActiveXObject ("Wbemscripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.execQuery("select * from Win32_Keyboard");
var e = new Enumerator (properties);
document.write("<table border=1>");
for (;!e.atEnd();e.moveNext ())
{
var p = e.item ();
document.write("<tr>");
document.write("<td>" + p.Description + "</td>");
document.write("<td>" + p.Name + "</td>");
document.write("<td>" + p.Status + "</td>");
document.write("</tr>");
}
document.write("</table>");
}
function Button1_onclick() {//主板信息
var locator = new ActiveXObject ("Wbemscripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.execQuery("select * from Win32_BaseBoard");
var e = new Enumerator (properties);
document.write("<table border=1>");
for (;!e.atEnd();e.moveNext ())
{
var p = e.item ();
document.write("<tr>");
document.write("<td>" + p.HostingBoard + "</td>");
document.write("<td>" + p.Manufacturer + "</td>");
document.write("<td>" + p.PoweredOn + "</td>");
document.write("<td>" + p.Product + "</td>");
document.write("<td>" + p.SerialNumber + "</td>");
document.write("<td>" + p.Version + "</td>");
document.write("</tr>");
}
document.write("</table>");
}
//-->
</script>
</head>
<body>
<INPUT id="Button1" type="button" value="Button"
name="Button1" language=javascript onclick="return Button1_onclick()">
</body>
</html>
使用javascript方式獲得客戶端的信息主要的優(yōu)點(diǎn)是,不需求服務(wù)器資源.不需求刷新網(wǎng)頁.直接在客戶端執(zhí)行腳本獲得顯示.
在這上找到了硬盤序列號(hào)的參數(shù):
\'獲得硬盤序列號(hào)Dim cmicWmi As New System.Management.ManagementObjectSearcher(\"select * from Win32_DiskDrive\")Dim Uint32 As UInt32For Each cmicWmiObj As ManagementObject In cmicWmi.GetUint32 = cmicWmiObj(\"signature\")NextTextBox1.Text = Uint32.ToString和在一塊總算給提出來了,呵呵。
該文章在 2022/7/14 17:36:58 編輯過