VB.NET 2005 获取硬件信息(包括CPU、主板、BOIS、显卡、内存、网络、存储介质等)

来源:互联网 发布:淘宝服装外景拍摄技巧 编辑:程序博客网 时间:2024/05/17 11:57
Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        get_CPU_info()
        get_net_info()
        get_op_info()
        get_net2_info()
        get_disk_info()
        get_disk_2_info()
        get_disp_info()
        get_bois_info()
        get_base_info()
        get_PhysicalMemoryy_info()
    End Sub
    Private Sub get_CPU_info()
        Dim info(40) As String
        Dim name(40) As String
        name(0) = "DeviceID"
        name(1) = "ProcessorID"
        name(2) = "Manufacturer"
        name(3) = "Name"
        name(4) = "Description"
        name(5) = "UniqueId"
        name(6) = "SocketDesignation"
        name(7) = "AddressWidth"
        name(8) = "DataWidth"
        name(9) = "Family"
        name(10) = "Level"
        name(11) = "Stepping"
        name(12) = "MaxClockSpeed"
        name(13) = "CurrentClockSpeed"
        name(14) = "InstallDate"
        name(15) = "PNPDeviceID"
        name(16) = "L2CacheSize"
        name(17) = "L2CacheSpeed"
        name(18) = "L3CacheSize"
        name(19) = "L3CacheSpeed"
        name(20) = "Architecture "
        name(21) = "Availability"
        name(22) = "CurrentVoltage"
        name(23) = "ProcessorType"
        name(24) = "StatusInfo"
        name(25) = "UpgradeMethod"
        name(26) = "VoltageCaps"
        name(27) = "VoltageCaps"
        Dim i As Integer
        Dim cpu As New System.Management.ManagementObjectSearcher("SELECT * FROM Win32_Processor")
        For Each obj1 As System.Management.ManagementObject In cpu.Get
            Try
                info(0) = obj1("DeviceID")
            Catch ex As Exception
                info(0) = ""
            End Try
            Try
                info(1) = obj1("ProcessorID").ToString.Trim
            Catch ex As Exception
                info(1) = ""
            End Try
            Try
                info(2) = obj1("Manufacturer").ToString.Trim
            Catch ex As Exception
                info(2) = ""
            End Try
            Try
                info(3) = obj1("Name").ToString.Trim
            Catch ex As Exception
                info(3) = ""
            End Try
            Try
                info(4) = obj1("Description").ToString.Trim
            Catch ex As Exception
                info(4) = ""
            End Try
            Try
                info(5) = obj1("UniqueId")
            Catch ex As Exception
                info(5) = ""
            End Try
            Try
                info(6) = obj1("SocketDesignation")
            Catch ex As Exception
                info(6) = ""
            End Try
            Try
                info(7) = obj1("AddressWidth")
            Catch ex As Exception
                info(7) = ""
            End Try
            Try
                info(8) = obj1("DataWidth")
            Catch ex As Exception
                info(8) = ""
            End Try
            Try
                info(9) = obj1("Family")
            Catch ex As Exception
                info(9) = ""
            End Try
            Try
                info(10) = obj1("Level")
            Catch ex As Exception
                info(10) = ""
            End Try
            Try
                info(11) = obj1("Stepping")
            Catch ex As Exception
                info(11) = ""
            End Try
            Try
                info(12) = obj1("MaxClockSpeed")
            Catch ex As Exception
                info(12) = ""
            End Try
            Try
                info(13) = obj1("CurrentClockSpeed")
            Catch ex As Exception
                info(13) = ""
            End Try
            Try
                info(14) = obj1("InstallDate")
            Catch ex As Exception
                info(14) = ""
            End Try
            Try
                info(15) = obj1("PNPDeviceID")
            Catch ex As Exception
                info(15) = ""
            End Try
            Try
                info(16) = obj1("L2CacheSize")
            Catch ex As Exception
                info(16) = ""
            End Try
            Try
                info(17) = obj1("L2CacheSpeed")
            Catch ex As Exception
                info(17) = ""
            End Try
            Try
                info(18) = obj1("L3CacheSize")
            Catch ex As Exception
                info(18) = ""
            End Try
            Try
                info(19) += obj1("L3CacheSpeed")
            Catch ex As Exception
                info(19) = ""
            End Try
            Try
                Select Case obj1("Architecture").ToString
                    Case "0"
                        info(20) = "x86"
                    Case "1"
                        info(20) = "MIPS"
                    Case "2"
                        info(20) = "Alpha"
                    Case "3"
                        info(20) = "PowerPC"
                    Case "6"
                        info(20) = "Intel Itanium Processor Family (IPF)"
                    Case "9"
                        info(20) = "x64"
                    Case Else
                        info(20) = obj1("Architecture").ToString
                End Select
            Catch ex As Exception
                info(20) = ""
            End Try
            Try
                info(21) = obj1("Availability")
            Catch ex As Exception
                info(21) = ""
            End Try
            Try
                info(22) = obj1("CurrentVoltage")
            Catch ex As Exception
                info(22) = ""
            End Try
            Try
                Select Case obj1("ProcessorType")
                    Case "1"
                        info(23) = "Other"
                    Case "2"
                        info(23) = "Unknown"
                    Case "3"
                        info(23) = "Central Processor"
                    Case "4"
                        info(23) = "Math Processor"
                    Case "5"
                        info(23) = "DSP Processor"
                    Case "6"
                        info(23) = "Video Processor"
                    Case Else
                        info(23) = obj1("ProcessorType")
                End Select
            Catch ex As Exception
                info(23) = ""
            End Try
            Try
                Select Case obj1("StatusInfo")
                    Case "1"
                        info(24) = "Other"
                    Case "2"
                        info(24) = "Unknown"
                    Case "3"
                        info(24) = "Enabled"
                    Case "4"
                        info(24) = "Disabled"
                    Case "5"
                        info(24) = "Not Applicable"
                    Case Else
                        info(24) = obj1("StatusInfo")
                End Select
            Catch ex As Exception
                info(24) = ""
            End Try
            Try
                Select Case obj1("UpgradeMethod").ToString
                    Case "1"
                        info(25) = "Other"
                    Case "2"
                        info(25) = "Unknown"
                    Case "3"
                        info(25) = "Daughter Board"
                    Case "4"
                        info(25) = "ZIF Socket"
                    Case "5"
                        info(25) = "Replacement/Piggy Back"
                    Case "6"
                        info(25) = "None"
                    Case "7"
                        info(25) = "LIF Socket"
                    Case "8"
                        info(25) = "Slot 1"
                    Case "9"
                        info(25) = "Slot 2"
                    Case "10"
                        info(25) = "370 Pin Socket"
                    Case "11"
                        info(25) = "Slot A"
                    Case "12"
                        info(25) = "Slot M"
                    Case "13"
                        info(25) = "Socket 423"
                    Case "14"
                        info(25) = "Socket A (Socket 462)"
                    Case "15"
                        info(25) = "Socket 478"
                    Case "16"
                        info(25) = "Socket 754"
                    Case "17"
                        info(25) = "Socket 940"
                    Case "18"
                        info(25) = "Socket 939"
                    Case Else
                        info(25) = obj1("UpgradeMethod").ToString
                End Select
            Catch ex As Exception
                info(25) = ""
            End Try
            Dim tmp As UInt32
            Try
                tmp = obj1("VoltageCaps")
            Catch ex As Exception
                tmp = 0
            End Try
            Select Case tmp
                Case 0
                    info(26) = "Unknown"
                Case 1
                    info(26) = "5 volts"
                Case 2
                    info(26) = "3.3 volts"
                Case 3
                    info(26) = "2.9 volts"
                Case Else
                    info(26) = Hex$(tmp)
            End Select
            For i = 0 To 28
                Dim newitem1 As New ListViewItem(name(i))
                newitem1.SubItems.Add(info(i))
                List_cpu.Items.Add(newitem1)
            Next
        Next
    End Sub
    Private Sub get_net_info()
        Dim info(30) As String
        Dim name(30) As String
        name(0) = "DeviceID"
        name(1) = "MACAddress"
        name(2) = "Manufacturer"
        name(3) = "AdapterTypeID"
        name(4) = "AdapterType"
        name(5) = "Description"
        name(6) = "Name"
        name(7) = "ProductName"
        name(8) = "Caption"
        name(9) = "ServiceName"
        name(10) = "SystemCreationClassName"
        name(11) = "SystemName"
        name(12) = "TimeOfLastReset"
        name(13) = "ConfigManagerUserConfig"
        name(14) = "NetConnectionStatus"
        Dim i As Integer
        Dim net As New System.Management.ManagementObjectSearcher("select * from Win32_NetworkAdapter")
        For Each wmiobj As System.Management.ManagementObject In net.Get
            For i = 0 To 14
                Try
                    info(i) = wmiobj(name(i))
                Catch ex As Exception
                    info(i) = ""
                End Try
            Next
            For i = 0 To 15
                Dim newitem1 As New ListViewItem(name(i))
                newitem1.SubItems.Add(info(i))
                List_net.Items.Add(newitem1)
            Next
        Next
    End Sub

    Private Sub get_op_info()
        Dim info(30) As String
        Dim name(30) As String
        name(0) = "CSName"
        name(1) = "Caption"
        name(2) = "Version"
        name(3) = "BuildNumber"
        name(4) = "BuildType"
        name(5) = "OSType"
        name(6) = "OSProductsuite"
        name(7) = "OtherTypeDescription"
        Dim i As Integer
        Dim newitem As New ListViewItem("操作系统")
        List_op.Items.Add(newitem)
        Dim opt As New System.Management.ManagementObjectSearcher("Select * from Win32_OperatingSystem")
        For Each obj2 As System.Management.ManagementObject In opt.Get
            For i = 0 To 7
                Try
                    info(i) = obj2(name(i))
                Catch ex As Exception
                    info(i) = ""
                End Try
            Next
            For i = 0 To 8
                Dim newitem1 As New ListViewItem(name(i))
                newitem1.SubItems.Add(info(i))
                List_op.Items.Add(newitem1)
            Next
        Next


    End Sub
    Private Sub get_net2_info()
        Dim i As Integer
        Dim info(50) As String
        Dim name(50) As String
        name(0) = "Index"
        name(1) = "IPEnabled"
        name(2) = "Caption"
        name(3) = "MACAddress"
        name(4) = "IPAddress"
        name(5) = "DefaultIPGateway"
        name(6) = "IPSubnet"
        name(7) = "DNSServerSearchOrder"
        name(8) = "IPConnectionMetric"
        name(9) = "IPSecPermitIPProtocols"
        name(10) = "IPSecPermitTCPPorts"
        name(11) = "IPSecPermitUDPPorts"
        name(12) = "IPUseZeroBroadcast"
        name(13) = "IPFilterSecurityEnabled"
        name(14) = "IPPortSecurityEnabled"
        name(15) = "DefaultTOS"
        name(16) = "DefaultTTL"
        name(17) = "IPXMediaType"
        name(18) = "IPXAddress"
        name(19) = "IPXFrameType"
        name(20) = "IPXNetworkNumber"
        name(21) = "IPXVirtualNetNumber"
        name(22) = "ForwardBufferMemory"
        name(23) = "ServiceName"
        name(24) = "DHCPEnabled"
        name(25) = "DHCPLeaseExpires"
        name(26) = "DHCPLeaseObtained"
        name(27) = "DHCPServer"
        name(28) = "DNSDomain"
        name(29) = "DNSHostName"
        name(30) = "DNSEnabledForWINSResolution"
        name(31) = "DNSServerSearchOrder"
        name(32) = "IGMPLevel"
        name(33) = "TcpipNetbiosOptions"
        name(34) = "TcpMaxConnectRetransmissions"
        name(35) = "TcpMaxDataRetransmissions"
        name(36) = "TcpNumConnections"
        name(37) = "TcpUseRFC1122UrgentPointer"
        name(38) = "TcpWindowSize"
        name(39) = "WINSEnableLMHostsLookup"
        name(40) = "WINSHostLookupFile"
        name(41) = "WINSPrimaryServer"
        name(42) = "WINSScopeID"
        name(43) = "WINSSecondaryServer"
        Dim opt As New System.Management.ManagementObjectSearcher("Select * from Win32_NetworkAdapterConfiguration")
        For Each obj2 As System.Management.ManagementObject In opt.Get
            info(0) = obj2("Index")
            If CBool(obj2("IPEnabled")) Then
                Try
                    info(1) = "True"
                Catch ex As Exception
                    info(1) = ""
                End Try
                Try
                    info(2) = obj2("Caption")
                Catch ex As Exception
                    info(2) = ""
                End Try
                Try
                    info(3) = obj2("MACAddress")
                Catch ex As Exception
                    info(3) = ""
                End Try
                Try
                    info(4) = obj2("IPAddress")(0)
                Catch ex As Exception
                    info(4) = ""
                End Try
                Try
                    info(5) = obj2("DefaultIPGateway")(0)
                Catch ex As Exception
                    info(5) = ""
                End Try

                info(6) = obj2("IPSubnet")(0)
                Try
                    info(7) = obj2("DNSServerSearchOrder")(0)
                    info(7) = info(7) + "  备用:" + obj2("DNSServerSearchOrder")(1)
                Catch ex As Exception
                    info(7) = info(7) + "  备用:"
                End Try
                Try
                    info(8) = obj2("IPConnectionMetric")
                Catch ex As Exception
                    info(8) = ""
                End Try
                Try
                    info(9) = obj2("IPSecPermitIPProtocols")(0)
                Catch ex As Exception
                    info(9) = ""
                End Try
                Try
                    info(10) = obj2("IPSecPermitTCPPorts")(0)
                Catch ex As Exception
                    info(10) = ""
                End Try
                Try
                    info(11) = obj2("IPSecPermitUDPPorts")(0)
                Catch ex As Exception
                    info(11) = ""
                End Try
                Try
                    info(12) = obj2("IPUseZeroBroadcast")
                Catch ex As Exception
                    info(12) = ""
                End Try
                Try
                    info(13) = obj2("IPFilterSecurityEnabled")
                Catch ex As Exception
                    info(13) = ""
                End Try
                Try
                    info(14) = obj2("IPPortSecurityEnabled")
                Catch ex As Exception
                    info(14) = ""
                End Try
                Try
                    info(15) = obj2("DefaultTOS")
                Catch ex As Exception
                    info(15) = ""
                End Try
                Try
                    info(16) = obj2("DefaultTTL")
                Catch ex As Exception
                    info(16) = ""
                End Try
                Try
                    info(17) = obj2("IPXMediaType")
                Catch ex As Exception
                    info(17) = ""
                End Try
                Try
                    info(18) = obj2("IPXAddress")
                Catch ex As Exception
                    info(18) = ""
                End Try
                Try
                    info(19) = obj2("IPXFrameType")(0)
                Catch ex As Exception
                    info(19) = ""
                End Try
                Try
                    info(20) = obj2("IPXNetworkNumber")(0)
                Catch ex As Exception
                    info(20) = ""
                End Try
                Try
                    info(21) = obj2("IPXVirtualNetNumber")
                Catch ex As Exception
                    info(21) = ""
                End Try
                Try
                    info(22) = obj2("ForwardBufferMemory")
                Catch ex As Exception
                    info(22) = ""
                End Try
                Try
                    info(23) = obj2("ServiceName")
                Catch ex As Exception
                    info(23) = ""
                End Try
                Try
                    info(24) = obj2("DHCPEnabled")
                Catch ex As Exception
                    info(24) = ""
                End Try
                Try
                    info(25) = obj2("DHCPLeaseExpires").ToString
                Catch ex As Exception
                    info(25) = ""
                End Try
                Try
                    info(26) = obj2(" DHCPLeaseObtained").ToString
                Catch ex As Exception
                    info(26) = ""
                End Try
                Try
                    info(27) = obj2(" DHCPServer").ToString
                Catch ex As Exception
                    info(27) = ""
                End Try
                Try
                    info(28) = obj2(" DNSDomain").ToString
                Catch ex As Exception
                    info(28) = ""
                End Try
                Try
                    info(29) = obj2(" DNSHostName").ToString
                Catch ex As Exception
                    info(29) = ""
                End Try
                Try
                    info(30) = obj2(" DNSEnabledForWINSResolution").ToString
                Catch ex As Exception
                    info(30) = ""
                End Try
                Try
                    info(31) = obj2(" DNSServerSearchOrder")(0)
                Catch ex As Exception
                    info(31) = ""
                End Try
                Try
                    info(32) = obj2(" IGMPLevel")(0)
                Catch ex As Exception
                    info(32) = ""
                End Try
                Try
                    info(33) = obj2(" TcpipNetbiosOptions")(0)
                Catch ex As Exception
                    info(33) = ""
                End Try
                Try
                    info(34) = obj2(" TcpMaxConnectRetransmissions")(0)
                Catch ex As Exception
                    info(34) = ""
                End Try
                Try
                    info(35) = obj2(" TcpMaxDataRetransmissions")(0)
                Catch ex As Exception
                    info(35) = ""
                End Try
                Try
                    info(36) = obj2(" TcpNumConnections")(0)
                Catch ex As Exception
                    info(36) = ""
                End Try
                Try
                    info(37) = obj2(" TcpUseRFC1122UrgentPointer")(0)
                Catch ex As Exception
                    info(37) = ""
                End Try
                Try
                    info(38) = obj2(" TcpWindowSize")(0)
                Catch ex As Exception
                    info(38) = ""
                End Try
                Try
                    info(39) = obj2(" WINSEnableLMHostsLookup")(0)
                Catch ex As Exception
                    info(39) = ""
                End Try
                Try
                    info(40) = obj2(" WINSHostLookupFile")(0)
                Catch ex As Exception
                    info(40) = ""
                End Try
                Try
                    info(41) = obj2(" WINSPrimaryServer")(0)
                Catch ex As Exception
                    info(41) = ""
                End Try
                Try
                    info(42) = obj2(" WINSScopeID")(0)
                Catch ex As Exception
                    info(42) = ""
                End Try
                Try
                    info(43) = obj2(" WINSSecondaryServer")(0)
                Catch ex As Exception
                    info(43) = ""
                End Try
                For i = 0 To 44
                    Dim newitem1 As New ListViewItem(name(i))
                    newitem1.SubItems.Add(info(i))
                    List_net2.Items.Add(newitem1)
                Next
            End If
        Next
    End Sub
    Private Sub get_disk_info()
        Dim i As Integer
        Dim info(50) As String
        Dim name(50) As String
        name(0) = "Index"
        name(1) = "Caption"
        name(2) = "Description"
        name(3) = "DeviceID"
        name(4) = "Name"
        name(5) = "MediaType"
        name(6) = "Model"
        name(7) = "Manufacturer"
        name(8) = "InterfaceType"
        name(9) = "CreationClassName"
        name(10) = "CompressionMethod"
        name(11) = "Partitions"
        name(12) = "NumberOfMediaSupported"
        name(13) = "Size"
        name(14) = "MaxMediaSize"
        name(15) = "TotalHeads"
        name(16) = "TotalCylinders"
        name(17) = "TracksPerCylinder"
        name(18) = "TotalTracks"
        name(19) = "SectorsPerTrack"
        name(20) = "TotalSectors"
        name(21) = "BytesPerSector"
        name(22) = "MinBlockSize"
        name(23) = "MaxBlockSize"
        name(24) = "Availability"
        name(25) = "Capabilities"
        name(26) = "CapabilityDescriptions"
        name(27) = "DefaultBlockSize"
        name(28) = "FirmwareRevision"
        name(29) = "SCSIBus"
        name(30) = "SCSILogicalUnit"
        name(31) = "SCSIPort"
        name(32) = "SCSITargetId"
        name(33) = "SerialNumber"
        name(34) = "Signature"
        name(35) = "Status"
        name(36) = "StatusInfo"
        name(37) = "SystemCreationClassName"
        name(38) = "SystemName"

        Dim opt As New System.Management.ManagementObjectSearcher("Select * from Win32_DiskDrive")
        For Each obj2 As System.Management.ManagementObject In opt.Get
            Try
                info(0) = obj2("Index")
            Catch ex As Exception
                info(0) = ""
            End Try
            Try
                info(1) = obj2("Caption")
            Catch ex As Exception
                info(1) = ""
            End Try
            Try
                info(2) = obj2("Description")
            Catch ex As Exception
                info(2) = ""
            End Try
            Try
                info(3) = obj2("DeviceID")
            Catch ex As Exception
                info(3) = ""
            End Try
            Try
                info(4) = obj2("Name")
            Catch ex As Exception
                info(4) = ""
            End Try
            Try
                info(5) = obj2("MediaType")
            Catch ex As Exception
                info(5) = ""
            End Try
            Try
                info(6) = obj2("Model")
            Catch ex As Exception
                info(6) = ""
            End Try
            Try
                info(7) = obj2("Manufacturer")
            Catch ex As Exception
                info(7) = ""
            End Try
            Try
                info(8) = obj2("InterfaceType")
            Catch ex As Exception
                info(8) = ""
            End Try
            Try
                info(9) = obj2("CreationClassName")
            Catch ex As Exception
                info(9) = ""
            End Try
            Try
                info(10) = obj2("CompressionMethod")
            Catch ex As Exception
                info(10) = ""
            End Try
            Try
                info(11) = obj2("Partitions")
            Catch ex As Exception
                info(11) = ""
            End Try
            Try
                info(12) = obj2("NumberOfMediaSupported")
            Catch ex As Exception
                info(12) = ""
            End Try
            Try
                info(13) = obj2("Size")
            Catch ex As Exception
                info(13) = ""
            End Try
            Try
                info(14) = obj2("MaxMediaSize")
            Catch ex As Exception
                info(14) = ""
            End Try
            Try
                info(15) = obj2("TotalHeads")
            Catch ex As Exception
                info(15) = ""
            End Try
            Try
                info(16) = obj2("TotalCylinders")
            Catch ex As Exception
                info(16) = ""
            End Try
            Try
                info(17) = obj2("TracksPerCylinder")
            Catch ex As Exception
                info(17) = ""
            End Try
            Try
                info(18) = obj2("TotalTracks")
            Catch ex As Exception
                info(18) = ""
            End Try
            Try
                info(19) = obj2("SectorsPerTrack")
            Catch ex As Exception
                info(19) = ""
            End Try
            Try
                info(20) = obj2("TotalSectors")
            Catch ex As Exception
                info(20) = ""
            End Try
            Try
                info(21) = obj2("BytesPerSector")
            Catch ex As Exception
                info(21) = ""
            End Try
            Try
                info(22) = obj2("MinBlockSize")
            Catch ex As Exception
                info(22) = ""
            End Try
            Try
                info(23) = obj2("MaxBlockSize")
            Catch ex As Exception
                info(23) = ""
            End Try
            Try
                info(24) = obj2("Availability")
            Catch ex As Exception
                info(24) = ""
            End Try
            Try
                info(25) = obj2("Capabilities")(0)
            Catch ex As Exception
                info(25) = ""
            End Try
            Try
                info(26) = obj2("CapabilityDescriptions")(0)
            Catch ex As Exception
                info(26) = ""
            End Try
            Try
                info(27) = obj2("DefaultBlockSize")
            Catch ex As Exception
                info(27) = ""
            End Try
            Try
                info(28) = obj2("FirmwareRevision")
            Catch ex As Exception
                info(28) = ""
            End Try
            Try
                info(29) = obj2("SCSIBus")
            Catch ex As Exception
                info(29) = ""
            End Try
            Try
                info(30) = obj2("SCSILogicalUnit")
            Catch ex As Exception
                info(30) = ""
            End Try
            Try
                info(31) = obj2("SCSIPort")
            Catch ex As Exception
                info(31) = ""
            End Try
            Try
                info(32) = obj2("SCSITargetId")
            Catch ex As Exception
                info(32) = ""
            End Try
            Try
                info(33) = obj2("SerialNumber")
            Catch ex As Exception
                info(33) = ""
            End Try
            Try
                info(34) = obj2("Signature")
            Catch ex As Exception
                info(34) = ""
            End Try
            Try
                info(35) = obj2("Status")
            Catch ex As Exception
                info(35) = ""
            End Try
            Try
                info(36) = obj2("StatusInfo")
            Catch ex As Exception
                info(36) = ""
            End Try
            Try
                info(37) = obj2("SystemCreationClassName")
            Catch ex As Exception
                info(37) = ""
            End Try
            Try
                info(38) = obj2("SystemName")
            Catch ex As Exception
                info(38) = ""
            End Try
            For i = 0 To 39
                Dim newitem1 As New ListViewItem(name(i))
                newitem1.SubItems.Add(info(i))
                List_disk.Items.Add(newitem1)
            Next
        Next
    End Sub

    Private Sub get_disk_2_info()
        Dim i As Integer
        Dim info(50) As String
        Dim name(50) As String
        name(0) = "Id"
        name(1) = "Caption"
        name(2) = "Description"
        name(3) = "DeviceID"
        name(4) = "Name"
        name(5) = "Drive"
        name(6) = "MediaType"
        name(7) = "PNPDeviceID"
        name(8) = "MaxMediaSize"
        name(9) = "MaxBlockSize"
        name(10) = "Manufacturer"
        name(11) = "FileSystemFlags"
        name(12) = "DefaultBlockSize"
        name(13) = "FileSystemFlagsEx"
        name(14) = "Availability"
        name(15) = "CreationClassName"
        name(16) = "MaximumComponentLength"
        name(17) = "MfrAssignedRevisionLevel"
        name(18) = "MinBlockSize"
        name(19) = "NumberOfMediaSupported"
        name(20) = "RevisionLevel"
        name(21) = "VolumeSerialNumber"
        name(22) = "VolumeName"
        name(23) = "TransferRate"
        name(24) = "SystemName"
        name(25) = "SystemCreationClassName"
        name(26) = "Size"
        name(27) = "StatusInfo"
        name(28) = "Status"
        name(29) = "SerialNumber"
        name(30) = "SCSITargetId"
        name(31) = "SCSIPort"
        name(32) = "SCSIBus"
        name(33) = "SCSILogicalUnit"
        Dim j As Integer
        Dim opt As New System.Management.ManagementObjectSearcher("Select * from Win32_CDROMDrive")
        For Each obj2 As System.Management.ManagementObject In opt.Get
            For j = 0 To 33
                Try
                    info(j) = obj2(name(j))
                Catch ex As Exception
                    info(j) = ""
                End Try
            Next
            For i = 0 To 34
                Dim newitem1 As New ListViewItem(name(i))
                newitem1.SubItems.Add(info(i))
                List_disk.Items.Add(newitem1)
            Next
        Next
    End Sub

    Private Sub get_disp_info()
        Dim i As Integer
        Dim info(50) As String
        Dim name(50) As String
        Dim j As Integer
        name(0) = "Name"
        name(1) = "Caption"
        name(2) = "ColorPlanes"
        name(3) = "Description"
        name(4) = "RefreshRate"
        name(5) = "SettingID"
        name(6) = "VideoMode"
        name(7) = "VerticalResolution"
        name(8) = "SystemPaletteEntries"
        name(9) = "ReservedSystemPaletteEntries"
        name(10) = "BitsPerPixel"
        name(11) = "DeviceEntriesInAColorTable"
        name(12) = "DeviceSpecificPens"
        name(13) = "HorizontalResolution"
        Dim opt As New System.Management.ManagementObjectSearcher("Select * from Win32_DisplayControllerConfiguration")
        For Each obj2 As System.Management.ManagementObject In opt.Get
            For j = 0 To 13
                Try
                    info(j) = obj2(name(j))
                Catch ex As Exception
                    info(j) = ""
                End Try
            Next
            For i = 0 To 14
                Dim newitem1 As New ListViewItem(name(i))
                newitem1.SubItems.Add(info(i))
                List_disp.Items.Add(newitem1)
            Next
        Next
    End Sub
    Private Sub get_bois_info()
        Dim i As Integer
        Dim info(50) As String
        Dim name(50) As String
        Dim j As Integer
        name(0) = "Name"
        name(1) = "Caption"
        name(2) = "SerialNumber"
        name(3) = "Manufacturer"
        name(4) = "Description"
        name(5) = "PrimaryBIOS"
        name(6) = "Version"
        name(7) = "Status"
        name(8) = "BuildNumber"
        name(9) = "CodeSet"
        name(10) = "CurrentLanguage"
        name(11) = "IdentificationCode"
        name(12) = "InstallableLanguages"
        name(13) = "InstallDate"
        name(14) = "LanguageEdition"
        name(15) = "OtherTargetOS"
        name(16) = "ReleaseDate"
        name(17) = "SMBIOSBIOSVersion"
        name(18) = "SMBIOSMajorVersion"
        name(19) = "SMBIOSMinorVersion"
        name(20) = "SMBIOSPresent"
        name(21) = "SoftwareElementID"
        name(22) = "SoftwareElementState"
        name(23) = "TargetOperatingSystem"
        name(24) = "ListOfLanguages"
        name(25) = "BIOSVersion"
        name(26) = "BiosCharacteristics"
        Dim k As Integer
        Dim opt As New System.Management.ManagementObjectSearcher("Select * from Win32_BIOS")
        For Each obj2 As System.Management.ManagementObject In opt.Get
            For j = 0 To 23
                Try
                    info(j) = obj2(name(j))
                Catch ex As Exception
                    info(j) = ""
                End Try
            Next
            Try
                info(24) = ""
                For k = 0 To obj2(name(24)).length - 1
                    info(24) += obj2(name(24))(k)
                Next
            Catch ex As Exception
                info(24) = ""
            End Try
            Try
                info(25) = ""
                For k = 0 To obj2(name(25)).length - 1
                    info(25) += obj2(name(25))(k)
                Next
            Catch ex As Exception
                info(25) = ""
            End Try
            Try
                info(26) = ""
                For k = 0 To obj2(name(26)).length - 1
                    info(26) += obj2(name(26))(k)
                Next
            Catch ex As Exception
                info(26) = ""
            End Try

            For i = 0 To 27
                Dim newitem1 As New ListViewItem(name(i))
                newitem1.SubItems.Add(info(i))
                List_bois.Items.Add(newitem1)

            Next

        Next
    End Sub

    Private Sub get_base_info()
        Dim i As Integer
        Dim info(50) As String
        Dim name(50) As String
        Dim j As Integer
        name(0) = "Name"
        name(1) = "Caption"
        name(2) = "SerialNumber"
        name(3) = "Manufacturer"
        name(4) = "Description"
        name(5) = "Model"
        name(6) = "HostingBoard"
        name(7) = "HotSwappable"
        name(8) = "InstallDate"
        name(9) = "Version"
        name(10) = "Weight"
        name(11) = "Width"
        name(12) = "Depth"
        name(13) = "Height"
        name(14) = "Tag"
        name(15) = "Status"
        name(16) = "SKU"
        name(17) = "SlotLayout"
        name(18) = "SpecialRequirements"
        name(19) = "RequiresDaughterBoard"
        name(20) = "RequirementsDescription"
        name(21) = "Replaceable"
        name(22) = "Removable"
        name(23) = "Product"
        name(24) = "PoweredOn"
        name(25) = "PartNumber"
        name(26) = "OtherIdentifyingInfo"
        Dim opt As New System.Management.ManagementObjectSearcher("Select * from Win32_BaseBoard")
        For Each obj2 As System.Management.ManagementObject In opt.Get
            For j = 0 To 26
                Try
                    info(j) = obj2(name(j))
                Catch ex As Exception
                    info(j) = ""
                End Try
            Next
            For i = 0 To 27
                Dim newitem1 As New ListViewItem(name(i))
                newitem1.SubItems.Add(info(i))
                List_main.Items.Add(newitem1)
            Next
        Next
        get_mother_info()
        get_on_bord_info()
    End Sub

    Private Sub get_mother_info()
        Dim i As Integer
        Dim info(50) As String
        Dim name(50) As String
        Dim j As Integer
        name(0) = "Name"
        name(1) = "Caption"
        name(2) = "PNPDeviceID"
        name(3) = "DeviceID"
        name(4) = "Description"
        name(5) = "Availability"
        name(6) = "ConfigManagerErrorCode"
        name(7) = "ConfigManagerUserConfig"
        name(8) = "CreationClassName"
        name(9) = "ErrorDescription"
        name(10) = "InstallDate"
        name(11) = "LastErrorCode"
        name(12) = "PowerManagementSupported"
        name(13) = "PrimaryBusType"
        name(14) = "RevisionNumber"
        name(15) = "SecondaryBusType"
        name(16) = "Status"
        name(17) = "StatusInfo"
        name(18) = "SystemCreationClassName"
        name(19) = "SystemName"
        Dim opt As New System.Management.ManagementObjectSearcher("Select * from Win32_MotherboardDevice")
        For Each obj2 As System.Management.ManagementObject In opt.Get
            For j = 0 To 19
                Try
                    info(j) = obj2(name(j))
                Catch ex As Exception
                    info(j) = ""
                End Try
            Next
            For i = 0 To 20
                Dim newitem1 As New ListViewItem(name(i))
                newitem1.SubItems.Add(info(i))
                List_main.Items.Add(newitem1)
            Next
        Next
    End Sub
    Private Sub get_on_bord_info()
        Dim i As Integer
        Dim info(50) As String
        Dim name(50) As String
        Dim j As Integer
        name(0) = "Name"
        name(1) = "Caption"
        name(2) = "PNPDeviceID"
        name(3) = "Description"
        name(4) = "Manufacturer"
        name(5) = "Model"
        name(6) = "SerialNumber"
        name(7) = "SKU"
        name(8) = "Status"
        name(9) = "Version"
        name(10) = "Tag"
        name(11) = "PartNumber"
        name(12) = "Replaceable"
        name(13) = "PoweredOn"
        name(14) = "DeviceType"
        name(15) = "CreationClassName"
        name(16) = "HotSwappable"
        name(17) = "Removable"
        name(18) = "InstallDate"
        name(19) = "OtherIdentifyingInfo"
        name(20) = "Enabled"
        Dim opt As New System.Management.ManagementObjectSearcher("Select * from Win32_OnBoardDevice")
        For Each obj2 As System.Management.ManagementObject In opt.Get
            For j = 0 To 20
                Try
                    info(j) = obj2(name(j))
                Catch ex As Exception
                    info(j) = ""
                End Try
            Next
            For i = 0 To 21
                Dim newitem1 As New ListViewItem(name(i))
                newitem1.SubItems.Add(info(i))
                List_main.Items.Add(newitem1)
            Next
        Next
    End Sub

    Private Sub get_PhysicalMemoryy_info()
        Dim i As Integer
        Dim info(50) As String
        Dim name(50) As String
        Dim j As Integer
        name(0) = "Tag"
        name(1) = "Name"
        name(2) = "Caption"
        name(3) = "Description"
        name(4) = "MemoryType"
        name(5) = "Manufacturer"
        name(6) = "Model"
        name(7) = "DeviceLocator"
        name(8) = "Capacity"
        name(9) = "SerialNumber"
        name(10) = "Version"
        name(11) = "PartNumber"
        name(12) = "DataWidth"
        name(13) = "Speed"
        name(14) = "Status"
        name(15) = "TotalWidth"
        name(16) = "TypeDetail"
        name(17) = "SKU"
        name(18) = "Replaceable"
        name(19) = "Removable"
        name(20) = "BankLabel"
        name(21) = "CreationClassName"
        name(22) = "FormFactor"
        name(23) = "HotSwappable"
        name(24) = "InstallDate"
        name(25) = "InterleaveDataDepth"
        name(26) = "InterleavePosition"
        name(27) = "OtherIdentifyingInfo"
        name(28) = "PositionInRow"
        name(29) = "PoweredOn"
        Dim newitem As New ListViewItem("物理内存")
        List_op.Items.Add(newitem)
        Dim opt As New System.Management.ManagementObjectSearcher("Select * from Win32_PhysicalMemory")
        For Each obj2 As System.Management.ManagementObject In opt.Get
            For j = 0 To 29
                Try
                    info(j) = obj2(name(j))
                Catch ex As Exception
                    info(j) = ""
                End Try
            Next
            For i = 0 To 30
                Dim newitem1 As New ListViewItem(name(i))
                newitem1.SubItems.Add(info(i))
                List_op.Items.Add(newitem1)
            Next
        Next
    End Sub


    
End Class
原创粉丝点击