1、WMI获取系统硬件信息WMI是英文Windows Management Instrumentation的简写,它的功能主要是:访问本地主机的一些信息和服务,可以管理远程计算机(当然你必须要拥有足够的权限),比如:重启,关机,关闭进程,创建进程等。 实例如下:用WMI,先工程-引用 Microsoft WMI Scripting V1.1 Library获取显卡/声卡/内存/操作系统的信息声卡信息Private Sub wmiSoundDeviceInfo()Dim wmiObjSet As SWbemObjectSetDim obj As SWbemObjectSet wmiObjSet =
2、GetObject(winmgmts:impersonationLevel=impersonate). _InstancesOf(Win32_SoundDevice)On Local Error Resume NextFor Each obj In wmiObjSetMsgBox obj.ProductNameNextEnd Sub显卡信息Private Sub wmiVideoControllerInfo()Dim wmiObjSet As SWbemObjectSetDim obj As SWbemObjectSet wmiObjSet = GetObject(winmgmts:imper
3、sonationLevel=impersonate). _InstancesOf(Win32_VideoController)On Local Error Resume NextFor Each obj In wmiObjSetMsgBox obj.VideoProcessorNextEnd Sub内存信息Private Sub wmiPhysicalMemoryInfo()Dim wmiObjSet As SWbemObjectSetDim obj As SWbemObjectSet wmiObjSet = GetObject(winmgmts:impersonationLevel=impe
4、rsonate). _InstancesOf(Win32_PhysicalMemory)On Local Error Resume NextFor Each objItem In wmiObjSetDebug.Print BankLabel: & objItem.BankLabelDebug.Print Capacity: & objItem.CapacityDebug.Print Caption: & objItem.CaptionDebug.Print CreationClassName: & objItem.CreationClassNameDebug.Print DataWidth:
5、& objItem.DataWidthDebug.Print Description: & objItem.DescriptionDebug.Print DeviceLocator: & objItem.DeviceLocatorDebug.Print FormFactor: & objItem.FormFactorDebug.Print HotSwappable: & objItem.HotSwappableDebug.Print InstallDate: & objItem.InstallDateDebug.Print InterleaveDataDepth: & objItem.Inte
6、rleaveDataDepthDebug.Print InterleavePosition: & objItem.InterleavePositionDebug.Print Manufacturer: & objItem.ManufacturerDebug.Print MemoryType: & objItem.MemoryTypeDebug.Print Model: & objItem.ModelDebug.Print Name: & objItem.nameDebug.Print OtherIdentifyingInfo: & objItem.OtherIdentifyingInfoDeb
7、ug.Print PartNumber: & objItem.PartNumberDebug.Print PositionInRow: & objItem.PositionInRowDebug.Print PoweredOn: & objItem.PoweredOnDebug.Print Removable: & objItem.RemovableDebug.Print Replaceable: & objItem.ReplaceableDebug.Print SerialNumber: & objItem.SerialNumberDebug.Print SKU: & objItem.SKUD
8、ebug.Print Speed: & objItem.SpeedDebug.Print Status: & objItem.StatusDebug.Print Tag: & objItem.TagDebug.Print TotalWidth: & objItem.TotalWidthDebug.Print TypeDetail: & objItem.TypeDetailDebug.Print Version: & objItem.VersionNextEnd Sub操作系统信息Private Sub Command1_Click()Dim wmiObjSet As SWbemObjectSe
9、tDim obj As SWbemObjectDim msg As StringDim dtb As StringDim d As StringDim t As StringDim bias As LongOn Local Error Resume NextSet wmiObjSet = GetObject(winmgmts:impersonationLevel=impersonate).InstancesOf(Win32_OperatingSystem)For Each obj In wmiObjSetMsgBox 你当前使用的系统是 & obj.CaptionNextEnd Sub说明:大
10、家可能会发现一个规律,实际上WMI对信息的提取都是使用了WIN32_类库名这样的规律,下列表格就是微软的操作系统各种硬件类的描述其它WMI管理的类的信息在可以找到,其中也还有部分示例代码简单Win_32类表Win32 ClassesMicrosoft? Windows? classes give you the means to manipulate a variety of objects. The following table identifies the categories of Windows classes.Category Description Computer system
11、 hardware Classes that represent hardware related objects. Operating system Classes that represent operating system related objects. Installed applications Classes that represent software related objects. WMI service management Classes used to manage WMI. Performance counters Classes that represent
12、formatted and raw performance data.硬件类Computer System Hardware Classeshe Cooling Devices subcategory groups classes that represent instrumentable fans, temperature probes, and refrigeration devices.Class Description Win32_Fan Represents the properties of a fan device in the computer system. Win32_He
13、atPipe Represents the properties of a heat pipe cooling device. Win32_Refrigeration Represents the properties of a refrigeration device. Win32_TemperatureProbe Represents the properties of a temperature sensor (electronic thermometer).Input Device ClassesThe Input Devices subcategory groups classes
14、that represent keyboards and pointing devices.Class Description Win32_Keyboard Represents a keyboard installed on a Windows system. Win32_PointingDevice Represents an input device used to point to and select regions on the display of a Windows computer system.Mass Storage ClassesClasses in the Mass
15、Storage subcategory represent storage devices such as hard disk drives, CD-ROM drives, and tape drives.Class Description Win32_AutochkSetting Represents the settings for the autocheck operation of a disk. Win32_CDROMDrive Represents a CD-ROM drive on a Windows computer system. Win32_DiskDrive Repres
16、ents a physical disk drive as seen by a computer running the Windows operating system. Win32_FloppyDrive Manages the capabilities of a floppy disk drive. Win32_PhysicalMedia Represents any type of documentation or storage medium. Win32_TapeDrive Represents a tape drive on a Windows computer.Motherbo
17、ard, Controller, and Port ClassesThe Motherboard, Controllers, and Ports subcategory groups classes that represent system devices. Examples include system memory, cache memory, and controllers.Class Description Win32_1394Controller Represents the capabilities and management of a 1394 controller. Win
18、32_1394ControllerDevice Relates the high-speed serial bus (IEEE 1394 Firewire) Controller and the CIM_LogicalDevice instance connected to it. Win32_AllocatedResource Relates a logical device to a system resource. Win32_AssociatedProcessorMemory Relates a processor and its cache memory. Win32_BaseBoa
19、rd Represents a baseboard (also known as a motherboard or system board). Win32_BIOS Represents the attributes of the computer systems basic input/output services (BIOS) that are installed on the computer. Win32_Bus Represents a physical bus as seen by a Windows operating system. Win32_CacheMemory Re
20、presents cache memory (internal and external) on a computer system. Win32_ControllerHasHub Represents the hubs downstream from the universal serial bus (USB) controller. Win32_DeviceBus Relates a system bus and a logical device using the bus. Win32_DeviceMemoryAddress Represents a device memory addr
21、ess on a Windows system. Win32_DeviceSettings Relates a logical device and a setting that can be applied to it. Win32_DMAChannel Represents a direct memory access (DMA) channel on a Windows computer system. Win32_FloppyController Represents the capabilities and management capacity of a floppy disk d
22、rive controller. Win32_IDEController Represents the capabilities of an Integrated Drive Electronics (IDE) controller device. Win32_IDEControllerDevice Association class that relates an IDE controller and the logical device. Win32_InfraredDevice Represents the capabilities and management of an infrar
23、ed device. Win32_IRQResource Represents an interrupt request line (IRQ) number on a Windows computer system. Win32_MemoryArray Represents the properties of the computer system memory array and mapped addresses. Win32_MemoryArrayLocation Relates a logical memory array and the physical memory array up
24、on which it exists. Win32_MemoryDevice Represents the properties of a computer systems memory device along with its associated mapped addresses. Win32_MemoryDeviceArray Relates a memory device and the memory array in which it resides. Win32_MemoryDeviceLocation Association class that relates a memor
25、y device and the physical memory on which it exists. Win32_MotherboardDevice Represents a device that contains the central components of the Windows computer system. Win32_OnBoardDevice Represents common adapter devices built into the motherboard (system board). Win32_ParallelPort Represents the pro
26、perties of a parallel port on a Windows computer system. Win32_PCMCIAController Manages the capabilities of a Personal Computer Memory Card Interface Adapter (PCMCIA) controller device. Win32_PhysicalMemory Represents a physical memory device located on a computer as available to the operating syste
27、m. Win32_PhysicalMemoryArray Represents details about the computer systems physical memory. Win32_PhysicalMemoryLocation Relates an array of physical memory and its physical memory. Win32_PNPAllocatedResource Represents an association between logical devices and system resources. Win32_PNPDevice Rel
28、ates a device (known to Configuration Manager as a PNPEntity), and the function it performs. Win32_PNPEntity Represents the properties of a Plug and Play device. Win32_PortConnector Represents physical connection ports, such as DB-25 pin male, Centronics, and PS/2. Win32_PortResource Represents an I
29、/O port on a Windows computer system. Win32_Processor Represents a device capable of interpreting a sequence of machine instructions on a Windows computer system. Win32_SCSIController Represents a small computer system interface (SCSI) controller on a Windows system. Win32_SCSIControllerDevice Relat
30、es a SCSI controller and the logical device (disk drive) connected to it. Win32_SerialPort Represents a serial port on a Windows system. Win32_SerialPortConfiguration Represents the settings for data transmission on a Windows serial port. Win32_SerialPortSetting Relates a serial port and its configu
31、ration settings. Win32_SMBIOSMemory Represents the capabilities and management of memory-related logical devices. Win32_SoundDevice Represents the properties of a sound device on a Windows computer system. Win32_SystemBIOS Relates a computer system (including data such as startup properties, time zones, boot configurations, or administrative passwords) and a system BIOS (services, languages, system management properties).
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1