vb程序求高手解答
使用WMI可以很方便的访问硬件/软件信息
在窗体里面插入一个列表框,然后代码
Private Sub Form_Load()
On Error Resume Next
Dim objWMIService, colItems, objItem
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor", , 48)
List1.AddItem "CPU详细信息"
List1.AddItem "----------------"
For Each objItem In colItems
List1.AddItem "AddressWidth: " & objItem.AddressWidth
List1.AddItem "Architecture: " & objItem.Architecture
List1.AddItem "Availability: " & objItem.Availability
List1.AddItem "Caption: " & objItem.Caption
List1.AddItem "ConfigManagerErrorCode: " & objItem.ConfigManagerErrorCode
List1.AddItem "ConfigManagerUserConfig: " & objItem.ConfigManagerUserConfig
List1.AddItem "CpuStatus: " & objItem.CpuStatus
List1.AddItem "CreationClassName: " & objItem.CreationClassName
List1.AddItem "CurrentClockSpeed: " & objItem.CurrentClockSpeed
List1.AddItem "CurrentVoltage: " & objItem.CurrentVoltage
List1.AddItem "DataWidth: " & objItem.DataWidth
List1.AddItem "Description: " & objItem.Description
List1.AddItem "DeviceID: " & objItem.DeviceID
List1.AddItem "ErrorCleared: " & objItem.ErrorCleared
List1.AddItem "ErrorDescription: " & objItem.ErrorDescription
List1.AddItem "ExtClock: " & objItem.ExtClock
List1.AddItem "Family: " & objItem.Family
List1.AddItem "InstallDate: " & objItem.InstallDate
List1.AddItem "L2CacheSize: " & objItem.L2CacheSize
List1.AddItem "L2CacheSpeed: " & objItem.L2CacheSpeed
List1.AddItem "LastErrorCode: " & objItem.LastErrorCode
List1.AddItem "Level: " & objItem.Level
List1.AddItem "LoadPercentage: " & objItem.LoadPercentage
List1.AddItem "Manufacturer: " & objItem.Manufacturer
List1.AddItem "MaxClockSpeed: " & objItem.MaxClockSpeed
List1.AddItem "Name: " & objItem.Name
List1.AddItem "OtherFamilyDescription: " & objItem.OtherFamilyDescription
List1.AddItem "PNPDeviceID: " & objItem.PNPDeviceID
List1.AddItem "PowerManagementCapabilities: " & objItem.PowerManagementCapabilities
List1.AddItem "PowerManagementSupported: " & objItem.PowerManagementSupported
List1.AddItem "ProcessorId: " & objItem.ProcessorId
List1.AddItem "ProcessorType: " & objItem.ProcessorType
List1.AddItem "Revision: " & objItem.Revision
List1.AddItem "Role: " & objItem.Role
List1.AddItem "SocketDesignation: " & objItem.SocketDesignation
List1.AddItem "Status: " & objItem.Status
List1.AddItem "StatusInfo: " & objItem.StatusInfo
List1.AddItem "Stepping: " & objItem.Stepping
List1.AddItem "SystemCreationClassName: " & objItem.SystemCreationClassName
List1.AddItem "SystemName: " & objItem.SystemName
List1.AddItem "UniqueId: " & objItem.UniqueId
List1.AddItem "UpgradeMethod: " & objItem.UpgradeMethod
List1.AddItem "Version: " & objItem.Version
List1.AddItem "VoltageCaps: " & objItem.VoltageCaps
List1.AddItem "---------------"
Next
List1.AddItem "内存详细信息"
List1.AddItem "----------------"
Set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemory", , 48)
For Each objItem In colItems
List1.AddItem "BankLabel: " & objItem.BankLabel
List1.AddItem "Capacity: " & objItem.Capacity
List1.AddItem "Caption: " & objItem.Caption
List1.AddItem "CreationClassName: " & objItem.CreationClassName
List1.AddItem "DataWidth: " & objItem.DataWidth
List1.AddItem "Description: " & objItem.Description
List1.AddItem "DeviceLocator: " & objItem.DeviceLocator
List1.AddItem "FormFactor: " & objItem.FormFactor
List1.AddItem "HotSwappable: " & objItem.HotSwappable
List1.AddItem "InstallDate: " & objItem.InstallDate
List1.AddItem "InterleaveDataDepth: " & objItem.InterleaveDataDepth
List1.AddItem "InterleavePosition: " & objItem.InterleavePosition
List1.AddItem "Manufacturer: " & objItem.Manufacturer
List1.AddItem "MemoryType: " & objItem.MemoryType
List1.AddItem "Model: " & objItem.Model
List1.AddItem "Name: " & objItem.Name
List1.AddItem "OtherIdentifyingInfo: " & objItem.OtherIdentifyingInfo
List1.AddItem "PartNumber: " & objItem.PartNumber
List1.AddItem "PositionInRow: " & objItem.PositionInRow
List1.AddItem "PoweredOn: " & objItem.PoweredOn
List1.AddItem "Removable: " & objItem.Removable
List1.AddItem "Replaceable: " & objItem.Replaceable
List1.AddItem "SerialNumber: " & objItem.SerialNumber
List1.AddItem "SKU: " & objItem.SKU
List1.AddItem "Speed: " & objItem.Speed
List1.AddItem "Status: " & objItem.Status
List1.AddItem "Tag: " & objItem.Tag
List1.AddItem "TotalWidth: " & objItem.TotalWidth
List1.AddItem "TypeDetail: " & objItem.TypeDetail
List1.AddItem "Version: " & objItem.Version
List1.AddItem "---------------"
Next
List1.AddItem "显卡信息"
List1.AddItem "----------------"
Set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemory", , 48)
For Each objItem In colItems
List1.AddItem "VideoProcessor: " & objItem.VideoProcessor
List1.AddItem "---------------"
Next
更多信息参考(看不懂就开Google翻译)
/library/aa394587