通过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