vb.net Display System Information

Source: Internet
Author: User
Display Display System Information
Example description
In this example, we get information about the operating system, the screen, and the power supply by using the SysInfo control. The results of the program run are shown in Figure 97-1.


Technical points
L Use the SysInfo control

L GET the operating system version number, power properties

Implementation process
New Project
Open Visual Studio.NET, select New Project, select Visual Basic project in the Project Type window, select Windows Application in the Template window, enter "SysInfo" in the Name field, and then select Save Path. Click "Confirm".

Adding controls
Add 10 Label controls to the form (you can arrange them by menu "format").

Setting properties
Change the Text property of the label control on the left column to the same as the interface.

Add code
Private Sub Form1_Load (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles MyBase.Load

' Gets the operating system platform code, where 1 represents the 95/98,2 representation nt/2000 system

Select case SysInfo. OSPlatform

Case 1

Label2.Text = "WINDOWS95/98"

Case 2

Label2.Text = "windowsnt/2000"

End Select

' Get the operating system version number

Label4.text = SysInfo. OSVersion & "." & SysInfo. Osbuild

' Get desktop size

Label6.text = SysInfo. Workareaheight & "X" & SysInfo. Workareawidth

' Get the power state value, 1 means the alternating current element, 0 means the battery

Select case SysInfo. Acstatus

Case 1

Label8.text = "AC power supply"

Case 0

Label8.text = "Battery"

End Select

' Get the battery time remaining, when the battery is AC power, return to-1, the other return 255

Select case SysInfo. Batterylifetime

Case-1

Label10.text = "Unknown"

Case Else

Label10.text = SysInfo. Batterylifetime

End Select

End Sub

Running programs
Click the Menu Debug | Start or click the icon to run the program.

Summary
All the properties of the SysInfo control are read-only, so we can only read them in code. By using the SysInfo control, you can help us create programs that are similar to Windows logon programs. That is, when we change the resolution of the system or plug or unplug a plug-and-Play device, our program responds to it. You can get operating system information, screen setup information, and power state information by using the SysInfo control. Where the size of the screen is not included by the Windows taskbar.







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.