实例如下:
用WMI,先工程-引用 Microsoft WMI Scripting V1.1 Library
获取显卡/声卡/内存/操作系统的信息
声卡信息
Private Sub wmiSoundDeviceInfo() Dim wmiObjSet As SWbemObjectSetDim obj As SWbemObject Set wmiObjSet = GetObject(winmgmts:{impersonationLevel=impersonate}). _InstancesOf(Win32_SoundDevice)On Local Error Resume Next For Each obj In wmiObjSetMsgBox obj.ProductNameNextEnd Sub |
---|
显卡信息
Private Sub wmiVideoControllerInfo() Dim wmiObjSet As SWbemObjectSetDim obj As SWbemObject Set wmiObjSet = GetObject(winmgmts:{impersonationLevel=impersonate}). _InstancesOf(Win32_VideoController) On Local Error Resume Next For Each obj In wmiObjSetMsgBox obj.VideoProcessorNextEnd Sub |
---|
内存信息
Private Sub wmiPhysicalMemoryInfo() Dim wmiObjSet As SWbemObjectSetDim obj As SWbemObject Set wmiObjSet = GetObject(winmgmts:{impersonationLevel=impersonate}). _InstancesOf(Win32_PhysicalMemory) On Local Error Resume Next For Each objItem In wmiObjSetDebug.Print BankLabel: & objItem.BankLabelDebug.Print Capacity: & objItem.CapacityDebug.Print Caption: & objItem.CaptionDebug.Print CreationClassName: & objItem.CreationClassNameDebug.Print DataWidth: & 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.InterleaveDataDepthDebug.Print InterleavePosition: & objItem.InterleavePositionDebug.Print Manufacturer: & objItem.ManufacturerDebug.Print MemoryType: & objItem.MemoryTypeDebug.Print Model: & objItem.ModelDebug.Print Name: & objItem.nameDebug.Print OtherIdentifyingInfo: & objItem.OtherIdentifyingInfoDebug.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.SKUDebug.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 SWbemObjectSetDim 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 |
---|
说明:
大家可能会发现一个规律,实际上WMI对信息的提取都是使用了WIN32_类库名这样的规律,下列表格就是微软的操作系统各种硬件类的描述