Visual Basic: SysInfo Control
This example uses a Label control on a form to show the status of the system's AC power. To run this example, put a SysInfo control, a Label control and a Timer control on a form. Paste this code into the Timer event of the Timer control. Set the Interval property of the Timer control to 5000, then run the example.
Private Sub Timer1_Timer() Select Case SysInfo1.ACStatus Case 0 Label1.Caption = "AC Power: Off" Case 1 Label1.Caption = "AC Power: On" Case 255 Label1.Caption = "AC Power: Unknown" End Select End Sub