WMI获取系统硬件信息

更新时间:2023-07-18 06:33:20 阅读: 评论:0

WMI是英文Windows Management Instrumentation的简写,它的功能主要是:访问本地主机的一些信息和服务,可以管理远程计算机(当然你必须要拥有足够的权限),比如:重启,关机,关闭进程,创建进程等。
实例如下:
'用WMI,先工程-引用 Microsoft WMI Scripting V1.1 Library
获取显卡/声卡/内存/操作系统的信息
明白的英文声卡信息
Private Sub wmiSoundDeviceInfo()
Dim wmiObjSet As SWbemObjectSet
Dim obj As SWbemObject
Set wmiObjSet = GetObject("winmgmts:{impersonationLevel=impersonate}"). _
InstancesOf("Win32_SoundDevice")
competition作文
On Local Error Resume Next
For Each obj In wmiObjSet
MsgBox obj.ProductName
Next
End Sub
显卡信息
Private Sub wmiVideoControllerInfo()
Dim wmiObjSet As SWbemObjectSet
Dim obj As SWbemObject
武汉考研辅导班Set wmiObjSet = GetObject("winmgmts:{impersonationLevel=impersonate}"). _
InstancesOf("Win32_VideoController")
On Local Error Resume Next美籍华人怎么翻译
For Each obj In wmiObjSet
suityourlfMsgBox obj.VideoProcessor
Next
End Sub
内存信息
Private Sub wmiPhysicalMemoryInfo()
Dim wmiObjSet As SWbemObjectSet
Dim obj As SWbemObject
Set wmiObjSet = GetObject("winmgmts:{impersonationLevel=impersonate}"). _
InstancesOf("Win32_PhysicalMemory")
On Local Error Resume Next
For Each objItem In wmiObjSet
Debug.Print "BankLabel: " & objItem.BankLabel
Debug.Print "Capacity: " & objItem.Capacity
Debug.Print "Caption: " & objItem.Caption
Debug.Print "CreationClassName: " & objItem.CreationClassName
Debug.Print "DataWidth: " & objItem.DataWidth
Debug.Print "Description: " & objItem.Description
Debug.Print "DeviceLocator: " & objItem.DeviceLocator
Debug.Print "FormFactor: " & objItem.FormFactor
Debug.Print "HotSwappable: " & objItem.HotSwappable
Debug.Print "InstallDate: " & objItem.InstallDate
Debug.Print "InterleaveDataDepth: " & objItem.InterleaveDataDepth布兰妮所有歌曲
Debug.Print "InterleavePosition: " & objItem.InterleavePosition
验货英文Debug.Print "Manufacturer: " & objItem.Manufacturer
Debug.Print "MemoryType: " & objItem.MemoryType
Debug.Print "Model: " & objItem.Model
Debug.Print "Name: " & objItem.name
Debug.Print "OtherIdentifyingInfo: " & objItem.OtherIdentifyingInfo
Debug.Print "PartNumber: " & objItem.PartNumber
Debug.Print "PositionInRow: " & objItem.PositionInRow
Debug.Print "PoweredOn: " & objItem.PoweredOn
Debug.Print "Removable: " & objItem.Removable
Debug.Print "Replaceable: " & objItem.Replaceable
Debug.Print "SerialNumber: " & objItem.SerialNumber
Debug.Print "SKU: " & objItem.SKU
Debug.Print "Speed: " & objItem.Speed
Debug.Print "Status: " & objItem.Status
Debug.Print "Tag: " & objItem.Tag
Debug.Print "TotalWidth: " & objItem.TotalWidth
Debug.Print "TypeDetail: " & objItem.TypeDetail
Debug.Print "Version: " & objItem.Version
Next
End Sub
操作系统信息
Private Sub Command1_Click()
Dim wmiObjSet As SWbemObjectSet
Dim obj As SWbemObject
Dim msg As String
Dim dtb As String
Dim d As String
Dim t As String
Dim bias As Long
On Local Error Resume Next
Set wmiObjSet = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_OperatingSystem")
For Each obj In wmiObjSet
MsgBox "你当前使用的系统是 " & obj.Caption
Next
End Sub
说明:
大家可能会发现一个规律,实际上WMI对信息的提取都是使用了WIN32_类库名这样的规律,下列表格就是微软的操作系统各种硬件类的描述
其它WMI管理的类的信息在
/library/default.asp?url=/library/en-us/wmisdk/wmi/accessing_hardware_and_software_through_wmi.asp
可以找到,其中也还有部分示例代码
简单Win_32类表
Win32 Class
Microsoft? Windows? class give you the means to manipulate a variety of objects. The following table identifies the categories of Windows class.
Category Description
Computer system hardware Class that reprent hardware related objects.
Operating system Class that reprent operating system related objects.
Installed applications Class that reprent software related objects.
WMI rvice management Class ud to manage WMI.
Performance counters Class that reprent formatted and raw performance data.
硬件类
Computer System Hardware Class
he Cooling Devices subcategory groups class that reprent instrumentable fans, temperature probes, and refrigeration devices.
Class Description
Win32_Fan Reprents the properties of a fan device in the computer system.
Win32_HeatPipe Reprents the properties of a heat pipe cooling device.
Win32_Refrigeration Reprents the properties of a refrigeration device.
Win32_TemperatureProbe Reprents the properties of a temperature nsor (electronic thermometer).
Input Device Class
陶文
考研英语作文万能模板The Input Devices subcategory groups class that reprent keyboards and pointing devices.
Class Description resistance
Win32_Keyboard Reprents a keyboard installed on a Windows system.
Win32_PointingDevice Reprents an input device ud to point to and lect regions on the display of a Windows computer system.
Mass Storage Class
Class in the Mass Storage subcategory reprent storage devices such as hard disk drives, CD-ROM drives, and tape drives.
Class Description
Win32_AutochkSetting Reprents the ttings for the autocheck operation of a disk.
Win32_CDROMDrive Reprents a CD-ROM drive on a Windows computer system.
Win32_DiskDrive Reprents a physical disk drive as en by a computer running the Windows operating system.
Win32_FloppyDrive Manages the capabilities of a floppy disk drive.
Win32_PhysicalMedia Reprents any type of documentation or storage medium.
Win32_TapeDrive Reprents a tape drive on a Windows computer.
Motherboard, Controller, and Port Class
The Motherboard, Controllers, and Ports subcategory groups class that reprent system devices. Examples include system memory, cache memory, and controllers.

本文发布于:2023-07-18 06:33:20,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/78/1102617.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:信息   规律   考研   进程
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图