JS獲取硬件信息代碼
當前位置:點晴教程→知識管理交流
→『 技術文檔交流 』
<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 Button1_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("CPU信息"); 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 Button2_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("軟盤信息"); 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 Button3_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("CD-ROM信息"); 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 Button4_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("鍵盤信息"); 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 Button5_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("主板信息"); 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>"); } function Button6_onclick() {//硬盤序列號 信息 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("硬盤信息"); 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>"); } function Button7_onclick() {//內(nèi)存 信息 var locator = new ActiveXObject ("WbemScripting.SWbemLocator"); var service = locator.ConnectServer("."); var properties = service.ExecQuery("SELECT * FROM Win32_ComputerSystem"); var e = new Enumerator (properties); document.write("內(nèi)存信息"); document.write("<table border=1>"); for (;!e.atEnd();e.moveNext ()) { var p = e.item (); document.write("<tr>"); document.write("<td>" + Math.ceil(p.TotalPhysicalMemory / 1024 / 1024 / 1024) + "</td>"); document.write("</tr>"); } document.write("</table>"); } Button1_onclick(); Button3_onclick(); Button4_onclick(); Button5_onclick(); Button6_onclick(); Button7_onclick(); //--> </script> </head> <body> </body> </html> 該文章在 2017/12/3 2:46:50 編輯過 |
關鍵字查詢
相關文章
正在查詢... |