VB中使用WMI获取系统硬件和软件有关信息[1]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 soho_andy 的 blog

在vb中使用wmi获取系统硬件和软件有关信息

简介:

      wmi是英文windows management
      instrumentation的简写,它的功能主要是:访问本地主机的一些信息和服务,可以管理远程计算机(当然你必须要拥有足够的权限),比如:重启,关机,关闭进程,创建进程等。

实例如下:

'用wmi,先工程-引用 microsoft wmi scripting v1.1 library

    获取显卡/声卡/内存/操作系统的信息

   声卡信息

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

 

显卡信息

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

内存信息

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

本文关键:WMI 系统 信息 硬件 软件
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top