如何使用excel vba获得当前电脑的信息?
发布网友
发布时间:2022-04-22 13:27
我来回答
共2个回答
热心网友
时间:2023-11-06 11:41
需要输入比较多的代码,具体参考如下:
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
————————
热心网友
时间:2023-11-06 11:41
录制个宏看一下代码