通過WMI來實現獲取客戶端計算機硬體及系統信息:
1//系統信息獲取
2function getSysInfo(){
3 var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
4 var service = locator.ConnectServer(".");
5 //CPU信息
6 var cpu = new Enumerator (service.ExecQuery("SELECT * FROM Win32_Processor")).item();
7 var cpuType=cpu.Name,hostName=cpu.SystemName;
8 //內存信息
9 var memory = new Enumerator (service.ExecQuery("SELECT * FROM Win32_PhysicalMemory"));
10 for (var mem=[],i=0; !memory.atEnd(); memory.moveNext()) mem[i++]={cap:memory.item().Capacity/1024/1024,speed:memory.item().Speed}
11 //系統信息
12 var system=new Enumerator (service.ExecQuery("SELECT * FROM Win32_ComputerSystem")).item();
13 var physicMenCap=Math.ceil(system.TotalPhysicalMemory/1024/1024),curUser=system.UserName,cpuCount=system.NumberOfProcessors
14
15 return {cpuType:cpuType,cpuCount:cpuCount,hostName:hostName,curUser:curUser,memCap:physicMenCap,mem:mem}
16}
B. html 或者HTML5 加上js能獲取手機設備的id號嗎
沒有 100% 准確的。開源方案可以用 WURFL:WURFL.io - Client Side, meet Server Side
瀏覽器navigator.userAgent提供了一專點設備信屬息:Mozilla/5.0 (iPhone; CPU iPhone OS 7_1_1 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Version/7.0 Mobile/11D201 Safari/9537.53