自 : http://club.excelhome.net/thread-395989-1-9.html
1. 获取主板序列号(注意并不是所有的主板都可以获得)
Sub 主板序列号() Dim objs As Object, Obj As Object, WMI As Object, 主板序列号 Set WMI = GetObject("WinMgmts:") Set objs = WMI.InstancesOf("Win32_BaseBoard") For Each Obj In objs MsgBox "您的主板序列号是:" + Obj.SerialNumber Next End Sub
2. 显示显卡信息
Sub 显卡信息() On Error Resume Next Dim tmp1, tmp2 Set tmp2 = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_VideoController") For Each tmp1 In tmp2 MsgBox "型 号: " & tmp1.VideoProcessor & vbCrLf & "厂 商: " & tmp1.AdapterCompatibility & vbCrLf & "名 称: " & tmp1.Name & vbCrLf & "状 态: " & tmp1.Status & vbCrLf & "显 存: " & (tmp1.AdapterRAM / 1024000) & "MB" & vbCrLf & "驱 动(dll): " & tmp1.InstalledDisplayDrivers & vbCrLf & "驱 动(inf): " & tmp1.infFilename & vbCrLf & "版 本: " & tmp1.DriverVersion Next End Sub
3. 显示网卡信息
Sub 网卡MAC() Dim 网卡 Set 网卡 = GetObject("Winmgmts:").InstancesOf("Win32_NetworkAdapterConfiguration") For Each 地址 In 网卡 If 地址.IPEnabled = True Then MsgBox "网卡MAC地址: " & 地址.MacAddress Exit For End If Next End Sub
4. 显示硬盘型号
Sub 硬盘型号() Dim 硬盘 Set 硬盘 = GetObject("Winmgmts:").InstancesOf("Win32_DiskDrive") For Each mo In 硬盘 MsgBox "硬盘型号为:" & mo.Model Next End Sub
5.显示cpu序列号
Sub CPU序列号() '特别提示:这个不是唯一的,即有可能多个CPU同一一序列号 For Each 序列 In GetObject("Winmgmts:").InstancesOf("Win32_Processor") MsgBox "CPU 序列号: " & CStr(序列.ProcessorId) Next End Sub
6.显示所有进行信息
Sub 所有进程() Set objs = GetObject("WinMgmts:").InstancesOf("Win32_Process") For Each obj In objs tmp = tmp & WorksheetFunction.Text(a + 1, "[DBNum2][$-804]0: ") + vbTab + obj.Description + Chr(13) a = a + 1 Next MsgBox tmp, 65, "提示你哦" End Sub