Display System Information
Instance description
In this example, we use the sysinfo control to obtain information about the operating system, screen, and power supply. The program running result is 97-1.
Technical Points
L use the SysInfo Control
L obtain the OS version number and power attribute
Implementation Process
■ Create a project
Open Visual Studio. NET, select "New Project", select "Visual Basic Project" in the project type window, select "Windows application" in the template window, and enter "SysInfo" in the name field ", then select the Save path. Click OK ".
■ Add controls
Add ten Label controls to the form (you can arrange them using the "format" menu ).
■ Set attributes
Change the Text attribute of the Label control in the left column to be consistent with that on the interface.
■ Add code
Private Sub Form1_Load (ByVal sender As System. Object, ByVal e As System. EventArgs) Handles MyBase. Load
'Get the operating system platform code, where 1 indicates 95/98, 2 indicates nt/2000 System
Select Case sysinfo. OSPlatform
Case 1
Label2.Text = "Windows95/98"
Case 2
Label2.Text = "WindowsNT/2000"
End Select
'Get the OS Version Number
Label4.Text = sysinfo. OSVersion & "." & sysinfo. OSBuild
'Get the desktop size
Label6.Text = sysinfo. WorkAreaHeight & "X" & sysinfo. WorkAreaWidth
'Obtain the power status value. 1 indicates the AC power, and 0 indicates the battery.
Select Case sysinfo. ACStatus
Case 1
Label8.Text = "AC power supply"
Case 0
Label8.Text = "battery"
End Select
'The batter' remaining time is obtained. When the batter' is AC power supply, the return value is-1, and the other return values are 255.
Select Case sysinfo. BatteryLifeTime