编程获取或者写入操作系统的信息, 只需要关注WMI consumers这一层. 通过C/C++之外的语言, 就仅仅考虑 COM API for WMI or the Scripting API for WMI 这两种方式的第二种.
Example: 通过ruby获取操作系统的版本信息, 采用Scripting API for WMI 这种方式
WIN32OLE.connect('winmgmts:\\\\.').ExecQuery("select * from Win32_OperatingSystem" ).each do |m|
p "#{m.Caption} SP#{m.ServicePackMajorVersion}"
end
WMI provides a uniform interface for any local or remote applications or scripts that obtain management data from a computer system, a network, or an enterprise. The uniform interface is designed such that WMI client applications and scripts do not have to call a wide variety of operating system application programming interfaces (APIs). Many APIs cannot be called by automation clients like scripts or Visual Basi