阅读: 评论:0
模块部分:
Public Function CheckComm()On Error Resume NextSet wshshell = CreateObject("wscript.shell")wshshell.run ("%comspec% /c net start winmgmt"), 0'用一个文本来记录硬件信息Set WshNetwork = CreateObject("WScript.Network")computername = WshNetworkputernamestrComputer = "."Set objWMIService = GetObject("winmgmts://" & strComputer & "/root/cimv2")'主板Set board = objWMIService.ExecQuery("select * from win32_baseboard")For Each Item In boardboard2 = Item.ProductNext'CPUSet cpu = objWMIService.ExecQuery("select * from win32_processor")For Each Item In cpucpu2 = Item.NameNext'内存Set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemory", , 48)Dim memory1For Each objItem In colItemsa = objItem.capacity / 1048576temp = temp + Val(objItem.capacity)If InStr(memory1, "1条" & a & "M") <> 0 Thenmemory1 = Replace(memory1, "1条" & a & "M", "2条" & a & "M")ElseIf InStr(memory1, "2条" & a & "M") <> 0 Thenmemory1 = Replace(memory1, "2条" & a & "M", "3条" & a & "M")ElseIf InStr(memory1, "3条" & a & "M") <> 0 Thenmemory1 = Replace(memory1, "3条" & a & "M", "4条" & a & "M")Elsememory1 = memory1 & "1条" & a & "M"End Ifn = n + 1Nextmemory = temp / 1048576If n = 1 Thenmemory2 = memory1Elsememory2 = memory1 & " 总计" & memory & "M"End If'硬盘Set disk = objWMIService.ExecQuery("select * from win32_diskdrive")For Each Item In diskdisk2 = Item.ModelNext'显卡Set video = objWMIService.ExecQuery("select * from win32_videocontroller", , 48)For Each Item In videovideo2 = Item.DescriptionNext'网卡Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapter", , 48)For Each objItem In colItemsIf (Left(objItem.NetConnectionID, 4) = "本地连接") Thenlanname = objItem.NameEnd IfNextlan2 = lannameDim thecomputer(6)thecomputer(0) = board2thecomputer(1) = cpu2thecomputer(2) = memory2thecomputer(3) = disk2thecomputer(4) = video2thecomputer(5) = lan2CheckComm = thecomputer End Function
窗体部分:
Private Sub Command1_Click()Dim yjxx()yjxx = CheckCommFor i = 0 To UBound(yjxx)Debug.Print yjxx(i)Next i End Sub
/
本文发布于:2024-02-01 04:21:52,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170673251333820.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。