前往小程序,Get更优阅读体验!
立即前往
发布
社区首页 >专栏 >VB中使用WMI获取系统硬件和软件有关信息的操作方法

VB中使用WMI获取系统硬件和软件有关信息的操作方法

原创
作者头像
大师级码师
发布2022-11-06 19:08:49
发布2022-11-06 19:08:49
9210
举报
文章被收录于专栏:大师级码师大师级码师

实例如下:

用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_类库名这样的规律,下列表格就是微软的操作系统各种硬件类的描述

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档