//获取系统信息
//参考 https://bbs.aardio.com/forum.php?mod=viewthread&tid=2477
//相关范例: 范例\操作系统\系统版本信息;范例\操作系统\硬件信息\查询硬件信息  


import console;
import com.wmi;
var wmi = com.wmi();
var osInfo = wmi.ExecQuery("Select * from Win32_OperatingSystem");
for index, o in com.each(osInfo) {
	console.log(o.Caption());//操作系统
	console.log(o.Version());//版本
}
console.more();

import sys.cpu;
var cpu = sys.cpu.getInfoByWmi()
console.log(cpu.deviceid());//CPU
console.log(cpu.name());//
console.log("CPU 核心数："+ cpu.numberOfCores);
console.log("CPU 逻辑核心数："+ cpu.numberOfLogicalProcessors);
console.log("CPU 最大速度："+ math.round(cpu.maxClockSpeed/1000,2) + "GHz");
console.log("CPU 当前速度："+ math.round(cpu.currentClockSpeed/1000,2) + "GHz");
console.log("CPU 位宽：" + cpu.addressWidth);
console.more()

var mem = wmi.instancesof("win32_physicalmemory")
for index,m in com.each(mem) { 
	console.log("内存容量",..math.size64(m.capacity()).format());
}
console.more();

var display = wmi.instancesof("Win32_videocontroller") 
for index, video in com.each(display) { 
	console.log(video.deviceid());//显示卡
	console.log(video.name());
}
console.more();

var colItems = wmi.ExecQuery("select * from Win32_NetworkAdapterConfiguration where IPEnabled=true",null,48)
if(colItems){
	for index, item in com.each(colItems) {
    	console.log(item.Description());//网卡
    	console.log(item.DefaultIPGateway(0));//默认网关：
    	console.log(item.DNSHostName(0));//计算机名
    	console.log(item.IPAddress(0));//IP地址
    	console.log(item.DNSServerSearchOrder(0));//默认 DNS
    	console.log(item.IPSubnet(0));//子网掩码
    	console.log(item.MACAddress());//M AC地址         
	}
}
console.more();
 
console.pause();