VB.net get the physical serial number and capacity of CPU and hard disk

Source: Internet
Author: User

First, reference the System.Management; then imports system.management in the code;

The following functions rely primarily on WMI implementations

Get the hard drive serial number

The code is as follows Copy Code
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
TextBox1.Text = uint32.tostring

  

Get CPU Serial Number

The code is as follows Copy Code

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

Get total drive capacity

The code is as follows Copy Code
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
TextBox1.Text = uint64.tostring

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.