求完整VB 6.0检测硬件代码,包括主板、CPU、硬盘、显卡、声卡及周边设备的型号、制造商、制造时间
若以下回答无法解决问题,邀请你更新回答
2013-07-27
展开全部
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数组控件
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数组控件
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询