通过WMI获得硬件信息

        'Dim MYIP As System.Net.IPHostEntry = System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName)
        'MsgBox("您的IP地址:" & MYIP.AddressList.GetValue(0).ToString)
        'MsgBox("您的计算机全名:" & MYIP.HostName.ToString)
        'MsgBox("您的系统:" & Environment.OSVersion.ToString)

        '得到显示器分辨率()
        'Dim X As Short = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width
        'Dim Y As Short = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height
        'MsgBox(X & "*" & Y)

        '桌面的路径
        'MsgBox(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory))
        '"Favorites"收藏夹路径
        'MsgBox(Environment.GetFolderPath(Environment.SpecialFolder.Favorites))
        '"Application Data"路径
        'MsgBox(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData))

        '取cpu id
        Dim ProcQuery As New SelectQuery("Win32_Processor")
        Dim ProcSearch As New ManagementObjectSearcher(ProcQuery)
        Dim ProcInfo As ManagementObject
        For Each ProcInfo In ProcSearch.Get()
            'MsgBox("ProcessorId: " & ProcInfo("ProcessorId".ToString()))
        Next

        '取主板ID  无效
        'Dim searcher As ManagementObjectSearcher = New ManagementObjectSearcher("Select   SerialNumber   From   Win32_BIOS")
        'Dim share As ManagementObject
        'For Each share In searcher.Get()
        ' MsgBox("序列号:" & share("SerialNumber"))
        'Next share

        '轮循网卡MAC地址
        'Dim Wmi As New System.Management.ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapterConfiguration")
        'Dim macadd As String
        'For Each WmiObj As ManagementObject In Wmi.Get
        'If CBool(WmiObj("IPEnabled")) Then
        'MsgBox("IP(" & WmiObj("IPAddress")(0) & ")|MAC(" & WmiObj("MACAddress") & ")")
        'macadd = macadd & Replace(WmiObj("MACAddress"), ":", "")
        'End If
        'Next
        'MsgBox(macadd)

        '获得硬盘序列号
        'Dim cmicWmi As New System.Management.ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive")
        'Dim Uint32 As UInt32
        'For Each cmicWmiObj As ManagementObject In cmicWmi.Get
        'UInt32 = cmicWmiObj("signature")
        'Next
        'MsgBox(UInt32.ToString)

        '获得硬盘总容量
        'Dim Wmi As New System.Management.ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive")
        'Dim Uint64 As UInt64
        'For Each WmiObj As ManagementObject In Wmi.Get
        'UInt64 = WmiObj("size")
        'Next
        'MsgBox(UInt64.ToString)


首先,引用System.Management;然后在代码中Imports System.Management;
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值