Excel 如何用VBA提取当前电脑的硬件信息
2个回答
推荐于2017-07-31
展开全部
需要输入比较多的代码,具体参考如下:
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
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
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
Sub 硬盘型号()
Dim 硬盘
Set 硬盘 = GetObject("Winmgmts:").InstancesOf("Win32_DiskDrive")
For Each mo In 硬盘
MsgBox "硬盘型号为:" & mo.Model
Next
End Sub
Sub CPU序列号()
'特别提示:这个不是唯一的,即有可能多个CPU同一一序列号
For Each 序列 In GetObject("Winmgmts:").InstancesOf("Win32_Processor")
MsgBox "CPU 序列号: " & CStr(序列.ProcessorId)
Next
End Sub
————————
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
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
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
Sub 硬盘型号()
Dim 硬盘
Set 硬盘 = GetObject("Winmgmts:").InstancesOf("Win32_DiskDrive")
For Each mo In 硬盘
MsgBox "硬盘型号为:" & mo.Model
Next
End Sub
Sub CPU序列号()
'特别提示:这个不是唯一的,即有可能多个CPU同一一序列号
For Each 序列 In GetObject("Winmgmts:").InstancesOf("Win32_Processor")
MsgBox "CPU 序列号: " & CStr(序列.ProcessorId)
Next
End Sub
————————
2016-11-25
展开全部
录制个宏看一下代码
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询