利用javascript wmi库取得计算机硬件信息的实列
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
利用javascript wmi库取得计算机硬件信息的实列
<%@taglib prefix="bean"uri="/WEB-INF/struts-bean.tld"%>
<%@taglib prefix="logic"uri="/WEB-INF/struts-logic.tld"%>
<%@taglib prefix="html"uri="/WEB-INF/struts-html.tld"%>
<%@page language="java"import="java.util.*"pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath =
request.getScheme()+"://"+request.getServerName()+":"+request.getServer Port()+path+"/";
%>
html:text{width:50}
var oCalendarEn=new PopupCalendar("oCalendarEn"); //初始化控件时,请给出实例名称如:oCalendarEn
oCalendarEn.Init();
var oCalendarChs=new PopupCalendar("oCalendarChs"); //初始化控件时,请给出实例名称:oCalendarChs
oCalendarChs.weekDaySting=new Array("日","一","二","三","四","五","六");
oCalendarChs.monthSting=new Array("一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月");
oCalendarChs.oBtnTodayTitle="今天";
oCalendarChs.oBtnCancelTitle="取消";
oCalendarChs.Init();
function getSysInfo(){
//debugger;
//硬件信息ActiveX
v ar locator = new ActiveXObject("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
//IP地址ActiveX
//var obj = new ActiveXObject("rcbdyctl.Setting");
var wsh = new ActiveXObject("WScript.Shell");
var cpu =
wsh.RegRead("HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\Central Processor\\0\\ProcessorNameString");
//var e = new Enumerator (service.ExecQuery("SELECT * FROM
Win32_Processor"));
var memory = new Enumerator(service.ExecQuery("select * from Win32_PhysicalMemory"));
var baseBoard = new Enumerator(service.ExecQuery("select * from Win32_BaseBoard"));
var disk = new Enumerator(service.ExecQuery("select * from
Win32_DiskDrive"));
var video = new Enumerator(service.ExecQuery("SELECT * FROM Win32_VideoController"));
var networkAdapter = new Enumerator(service.ExecQuery("select * from Win32_NetworkAdapterConfiguration"));
var printer = new Enumerator(service.ExecQuery("SELECT * FROM Win32_Printer"));
var from = document.forms[0];
var cupj = '';
cupj = cpu;
from.elements["computer.cpuInfo"].value=cupj;
var boardj = '';
//主板信息
for(;!baseBoard.atEnd();baseBoard.moveNext()){
var p = baseBoard.item();
boardj = p.Manufacturer+"--"+p.Product;
}
from.elements["computer.baseBoard"].value=boardj;
//内存信息
var memoryj = '';
var pcount = 0;
for (;!memory.atEnd();memory.moveNext ()){
var p = memory.item ();
pcount += parseInt(p.Capacity);
}
memoryj = pcount/1024/1024+"M";
from.elements["computer.memoryInfo"].value=memoryj;
//硬盘信息
var diskj = '';
for(;!disk.atEnd();disk.moveNext()){