Get the physical serial number of the hard disk and the CPU through WMI (VB.NET)

xiaoxiao2021-03-06  68

'Get hard disk serial numbers

DIM CMICWMI AS New System.Management.ManagementObjectSearcher ("SELECT * WIN32_DISKDRIVE")

DIM uint32 as uint32

For Each Cmicwmiobj As ManagementObject In Cmicwmi.get

UINT32 = CMICWMIOBJ ("SIGNATURE")

NEXT

TextBox1.text = uint32.toString

'Get CPU serial numbers

DIM WMI As New System.Management.ManagementObjectSearcher ("Select * from win32_processor")

DIM uint32 as string

For Each Wmiobj As ManagementObject in WMI.GET

UINT32 = WMIOBJ ("Processorid")

NEXT

TEXTBOX1.TEXT = uint32 'gets the total hard disk total capacity

DIM WMI AS New System.Management.ManagementObjectSearcher ("SELECT * WIN32_DISKDRIVE")

DIM uint64 as uint64

For Each Wmiobj As ManagementObject in WMI.GET

UINT64 = WMIOBJ ("size")

NEXT

TextBox1.text = uint64.tostring First, reference system.Management; then in the code in the code system.Management;

转载请注明原文地址:https://www.9cbs.com/read-110033.html

New Post(0)