DoEvents
temp = 0
Set wshshell = CreateObject("wscript.shell")
'启动WMI服务(没有这个服务就不行)
wshshell.run ("%comspec% /c regsvr32 /s scrrun.dll"), 0, True
wshshell.run ("%comspec% /c sc config winmgmt start= auto"), 0, True
wshshell.run ("%comspec% /c net start winmgmt"), 0
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
'主板
DoEvents
Set board = objWMIService.ExecQuery("select * from win32_baseboard")
For Each Item In board
board2 = board2 & "主板:" & Item.Product
Next
'CPU
DoEvents
Set cpu = objWMIService.ExecQuery("select * from win32_processor")
For Each Item In cpu
cpu2 = cpu2 & "CPU:" & Item.Name
Next
'内存
DoEvents
Set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemory", , 48)
For Each objItem In colItems
a = objItem.capacity
temp = temp + objItem.capacity
n = n + 1
Next
memory = temp / 1048576
If n = 1 Then
memory2 = "内存: " & n & "条" & a & "M"
Else
memory2 = "内存: " & n & "条" & a & "M" & " 总计" & memory & "M"
End If
'硬盘
DoEvents
Set disk = objWMIService.ExecQuery("select * from win32_diskdrive")
For Each Item In disk
disk2 = disk2 & "硬盘: " & Item.Model & " "
Next
'显卡
DoEvents
Set video = objWMIService.ExecQuery("select * from win32_videocontroller", , 48)
For Each Item In video
video2 = video2 & "显卡: " & Item.Description
Next
'网卡
DoEvents
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapter", , 48)
For Each objItem In colItems
If (Left(objItem.NetConnectionID, 4) = "本地连接") Then
lanname = lanname & objItem.Name
End If
Next
lan2 = "网卡: " & lanname
Text1(0).Text = board2: Text1(1).Text = cpu2: Text1(2).Text = memory2
Text1(3).Text = disk2: Text1(4).Text = video2: Text1(5).Text = lan2需要6个TEXT1数组控件