一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務器之家:專注于服務器技術及軟件下載分享
分類導航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術|正則表達式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務器之家 - 編程語言 - VB - VB中使用WMI獲取系統硬件和軟件有關信息

VB中使用WMI獲取系統硬件和軟件有關信息

2021-10-16 14:52ericbai VB

WMI是英文Windows Management Instrumentation的簡寫,它的功能主要是:訪問本地主機的一些信息和服務,可以管理遠程計算機(當然你必須要擁有足夠的權限),比如:重啟,關機,關閉進程,創建進程等

WMI是英文Windows Management Instrumentation的簡寫,它的功能主要是:訪問本地主機的一些信息和服務,可以管理遠程計算機(當然你必須要擁有足夠的權限),比如:重啟,關機,關閉進程,創建進程等。

當然此文是適用于vbscript

微軟官方的資料:

實例如下:

用WMI,先工程-引用 Microsoft WMI Scripting V1.1 Library

獲取顯卡/聲卡/內存/操作系統的信息

聲卡信息

?
1
2
3
4
5
6
7
8
9
10
11
12
13
Private Sub wmiSoundDeviceInfo()
 
Dim wmiObjSet As SWbemObjectSet
Dim obj As SWbemObject
 
Set wmiObjSet = GetObject(winmgmts:{impersonationLevel=impersonate}). _
InstancesOf(Win32_SoundDevice)
On Local Error Resume Next
 
For Each obj In wmiObjSet
MsgBox obj.ProductName
Next
End Sub

顯卡信息

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
MsgBox obj.VideoProcessor
Next
End Sub

內存信息

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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

操作系統信息

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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管理的類的信息在

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/accessing_hardware_and_software_through_wmi.asp

可以找到,其中也還有部分示例代碼

簡單Win_32類表

Win32 Classes
Microsoft® 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 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 formatted and raw performance data.

硬件類
Computer System Hardware Classes
he 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_HeatPipe 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 Classes

The Input Devices subcategory groups classes 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 Classes

Classes in the Mass 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 Represents 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.

Motherboard, Controller, and Port Classes

The 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.
Win32_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_BaseBoard Represents a baseboard (also known as a motherboard or system board).
Win32_BIOS Represents the attributes of the computer system's 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 Represents 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 address 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 drive 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 infrared 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 upon which it exists.
Win32_MemoryDevice Represents the properties of a computer system's memory device along with it's associated mapped addresses.
Win32_MemoryDeviceArray Relates a memory device and the memory array in which it resides.
Win32_MemoryDeviceLocation Association class that relates a memory 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 properties 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 system.
Win32_PhysicalMemoryArray Represents details about the computer system's 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 Relates 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/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 Relates 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 configuration 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).
Win32_SystemDriverPNPEntity Relates a Plug and Play device on the Windows computer system and the driver that supports the Plug and Play device.
Win32_SystemEnclosure Represents the properties associated with a physical system enclosure.
Win32_SystemMemoryResource Represents a system memory resource on a Windows system.
Win32_SystemSlot Represents physical connection points including ports, motherboard slots and peripherals, and proprietary connections points.
Win32_USBController Manages the capabilities of a universal serial bus (USB) controller.
Win32_USBControllerDevice Relates a USB controller and the CIM_LogicalDevice instances connected to it.
Win32_USBHub Represents the management characteristics of a USB hub.


Networking Device Classes

The Networking Devices subcategory groups classes that represent the network interface controller, its configurations, and its settings.

Class Description
Win32_NetworkAdapter Represents a network adapter on a Windows system.
Win32_NetworkAdapterConfiguration Represents the attributes and behaviors of a network adapter. The class is not guaranteed to be supported after the ratification of the Distributed Management Task Force (DMTF) CIM network specification.
Win32_NetworkAdapterSetting Relates a network adapter and its configuration settings.


Power Classes

The Power subcategory groups classes that represent power supplies, batteries, and events related to these devices.

Class Description
Win32_AssociatedBattery Relates a logical device and the battery it is using.
Win32_Battery Represents a battery connected to the computer system.
Win32_CurrentProbe Represents the properties of a current monitoring sensor (ammeter).
Win32_PortableBattery Represents the properties of a portable battery, such as one used for a notebook computer.
Win32_PowerManagementEvent Represents power management events resulting from power state changes.
Win32_UninterruptiblePowerSupply Represents the capabilities and management capacity of an uninterruptible power supply (UPS).
Win32_VoltageProbe Represents the properties of a voltage sensor (electronic voltmeter).


Printing Classes

The Printing subcategory groups classes that represent printers, printer configurations, and print jobs.

Class Description
Win32_DriverForDevice Relates a printer to a printer driver.
Win32_Printer Represents a device connected to a Windows computer system that is capable of reproducing a visual image on a medium.
Win32_PrinterConfiguration Defines the configuration for a printer device.
Win32_PrinterController Relates a printer and the local device to which the printer is connected.
Win32_PrinterDriver Represents the drivers for a Win32_Printer instance.
Win32_PrinterDriverDll Relates a local printer and its driver file (not the driver itself).
Win32_PrinterSetting Relates a printer and its configuration settings.
Win32_PrintJob Represents a print job generated by a Windows application.
Win32_TCPIPPrinterPort Represents a TCP/IP service access point.

Telephony Classes

The Telephony subcategory groups classes that represent plain old telephone modem devices and their associated serial connections.

Class Description
Win32_POTSModem Represents the services and characteristics of a Plain Old Telephone Service (POTS) modem on a Windows system.
Win32_POTSModemToSerialPort Relates a modem and the serial port the modem uses.


Video and Monitor Classes

The Video and Monitors subcategory groups classes that represent monitors, video cards, and their associated settings.

Class Description
Win32_DesktopMonitor Represents the type of monitor or display device attached to the computer system.
Win32_DisplayConfiguration Represents configuration information for the display device on a Windows system. This class is obsolete. In place of this class, use the properties in the Win32_VideoController, Win32_DesktopMonitor, and CIM_VideoControllerResolution classes.
Win32_DisplayControllerConfiguration Represents the video adapter configuration information of a Windows system. This class is obsolete. In place of this class, use the properties in the Win32_VideoController, Win32_DesktopMonitor, and CIM_VideoControllerResolution classes.
Win32_VideoConfiguration This class has been eliminated from Windows XP and later; attempts to use it will generate a fatal error. In place of this class, use the properties contained in the Win32_VideoController, Win32_DesktopMonitor, and CIM_VideoControllerResolution classes.
Win32_VideoController Represents the capabilities and management capacity of the video controller on a Windows computer system.
Win32_VideoSettings Relates a video controller and video settings that can be applied to it.

 

而每一個類都有對應的數據結構如

顯卡

class Win32_VideoController : CIM_PCVideoController
{
uint16 AcceleratorCapabilities[];
string AdapterCompatibility;
string AdapterDACType;
uint32 AdapterRAM;
uint16 Availability;
string CapabilityDescriptions[];
string Caption;
uint32 ColorTableEntries;
uint32 ConfigManagerErrorCode;
boolean ConfigManagerUserConfig;
string CreationClassName;
uint32 CurrentBitsPerPixel;
uint32 CurrentHorizontalResolution;
uint64 CurrentNumberOfColors;
uint32 CurrentNumberOfColumns;
uint32 CurrentNumberOfRows;
uint32 CurrentRefreshRate;
uint16 CurrentScanMode;
uint32 CurrentVerticalResolution;
string Description;
string DeviceID;
uint32 DeviceSpecificPens;
uint32 DitherType;
datetime DriverDate;
string DriverVersion;
boolean ErrorCleared;
string ErrorDescription;
uint32 ICMIntent;
uint32 ICMMethod;
string InfFilename;
string InfSection;
datetime InstallDate;
string InstalledDisplayDrivers;
uint32 LastErrorCode;
uint32 MaxMemorySupported;
uint32 MaxNumberControlled;
uint32 MaxRefreshRate;
uint32 MinRefreshRate;
boolean Monochrome;
string Name;
uint16 NumberOfColorPlanes;
uint32 NumberOfVideoPages;
string PNPDeviceID;
uint16 PowerManagementCapabilities[];
boolean PowerManagementSupported;
uint16 ProtocolSupported;
uint32 ReservedSystemPaletteEntries;
uint32 SpecificationVersion;
string Status;
uint16 StatusInfo;
string SystemCreationClassName;
string SystemName;
uint32 SystemPaletteEntries;
datetime TimeOfLastReset;
uint16 VideoArchitecture;
uint16 VideoMemoryType;
uint16 VideoMode;
string VideoModeDescription;
string VideoProcessor;
};

聲卡等

class Win32_SoundDevice : CIM_LogicalDevice
{
uint16 Availability;
string Caption;
uint32 ConfigManagerErrorCode;
boolean ConfigManagerUserConfig;
string CreationClassName;
string Description;
string DeviceID;
uint16 DMABufferSize;
boolean ErrorCleared;
string ErrorDescription;
datetime InstallDate;
uint32 LastErrorCode;
string Manufacturer;
uint32 MPU401Address;
string Name;
string PNPDeviceID;
uint16 PowerManagementCapabilities[];
boolean PowerManagementSupported;
string ProductName;
string Status;
uint16 StatusInfo;
string SystemCreationClassName;
string SystemName;
};

class Win32_PrintJob : CIM_Job
{
string Caption;
string DataType;
string Description;
string Document;
string DriverName;
datetime ElapsedTime;
string HostPrintQueue;
datetime InstallDate;
uint32 JobId;
string JobStatus;
string Name;
string Notify;
string Owner;
uint32 PagesPrinted;
string Parameters;
string PrintProcessor;
uint32 Priority;
uint32 Size;
datetime StartTime;
string Status;
uint32 StatusMask;
datetime TimeSubmitted;
uint32 TotalPages;
datetime UntilTime;
};

Set wmiObjSet = GetObject(winmgmts:{impersonationLevel=impersonate}). _
InstancesOf(Win32_PrintJob)

可以獲得打印任務列表等信息

對于VB來講獲得系統硬件和軟件信息大都使用API,現在使用WMI可以快速的實現我們的目標.如獲取驅動器/顯卡/共享信息等等都會變得方便和有效

延伸 · 閱讀

精彩推薦
  • VBVB鍵盤鼠標無動作調用程序的嘗試

    VB鍵盤鼠標無動作調用程序的嘗試

    這篇文章主要介紹了VB鍵盤鼠標無動作調用程序的嘗試,記錄下整個思路和過程,有需要的小伙伴可以參考下。...

    VB教程網4452021-10-15
  • VBVB的TextBox文本框實現垂直居中顯示的方法

    VB的TextBox文本框實現垂直居中顯示的方法

    這篇文章主要介紹了VB的TextBox文本框實現垂直居中顯示的方法,比較實用的功能,需要的朋友可以參考下...

    VB教程網15092021-10-11
  • VBVB6實現連接Access數據庫的ADODB代碼實現方法

    VB6實現連接Access數據庫的ADODB代碼實現方法

    這篇文章主要介紹了VB6實現連接Access數據庫的ADODB代碼實現方法,對于初學者掌握VB鏈接access數據庫有著很好的借鑒價值,需要的朋友可以參考下...

    VB教程網9832021-10-11
  • VBVB關機惡搞小程序

    VB關機惡搞小程序

    本文給大家匯總了一些使用VB實現的關機惡搞小程序,大家娛樂一下就行了,千萬別做壞事哦...

    VB教程網10142021-10-16
  • VBVB獲取文件大小的方法

    VB獲取文件大小的方法

    這篇文章主要介紹了VB獲取文件大小的方法,可實現準確獲取文件大小的功能,需要的朋友可以參考下...

    小卒過河13192021-10-15
  • VBVB實現的16位和32位md5加密代碼分享

    VB實現的16位和32位md5加密代碼分享

    這篇文章主要介紹了VB實現的16位和32位md5加密代碼分享,需要的朋友可以參考下...

    VB.NET教程網8592021-10-08
  • VB分享如何在VB中調用VC編寫的DLL

    分享如何在VB中調用VC編寫的DLL

    一般來說,VB和VC共同編程有3種方式:一種是VC生成DLL,在VB中調用DLL;一種是VC生成ActiveX控件(.ocx),在VB中插入;還有一種是在VC中生成ActiveX Automation服務器...

    VB教程網4452021-10-07
  • VBVB返回記錄集結果到HTML表格的方法

    VB返回記錄集結果到HTML表格的方法

    這篇文章主要介紹了VB返回記錄集結果到HTML表格的方法,實例分析了VB獲取記錄集與HTML表格生成的相關技巧,需要的朋友可以參考下...

    小卒過河10682021-10-15
主站蜘蛛池模板: 无码爽死成人777在线观看网站 | 欧美日本道免费一区二区三区 | 免费国产午夜高清在线视频 | 香蕉久久综合 | 狠狠婷婷综合缴情亚洲 | 男人捅女人动漫 | 亚洲九九九 | 99午夜| 天天色天天色天天色 | 免费视频精品一区二区三区 | 婷婷色在线 | 色卡7707c| 九九精品视频在线观看九九 | 欧美日韩久久中文字幕 | 日本热妇 | 男同精品视频免费观看网站 | 女王脚奴vk| 精品欧美男同同性videos | 交换朋友夫妇3中文字幕 | 深夜激情网站 | 亚洲美女aⅴ久久久91 | 色婷婷在线视频 | 啪啪模拟器| 国产东北三老头伦一肥婆 | 免费看全黄特黄毛片 | 91大神在线观看精品一区 | 26uuu久久| 女性全身裸露无遮挡 | 国产成人一区二区三区在线视频 | 青草网在线观看 | 天天色天天舔 | 暖暖视频免费观看视频中国.韩剧 | 暖暖 免费 高清 中文 日本 | 亚洲精品午夜级久久久久 | 国产日韩一区二区三区 | 亚洲国产精品一区二区久久 | 女人和拘做受全过程免费 | 久久综合中文字幕佐佐木希 | 国产精品每日在线观看男人的天堂 | 久久AV喷吹AV高潮欧美 | 国产精品中文字幕 |