Platform: SharpDeveloper
Okay, basically, I've just gotten this piece of code to get the Battery Level on a notebook.
Problem is, I've no idea as to how to go ahead and utilise this piece of code to get the desired battery level. Maybe... do I need to perhaps insert a label to display the Print statuses?
I've also realised it's the norm for people to post codes like this when it comes to VB.NET. But how do the coder, who uses the code, get the code working? (Definitely not copy-pasting everything, yeah?)
So I guess a general answer is enough. Pls help.
Thanks.
Okay, basically, I've just gotten this piece of code to get the Battery Level on a notebook.
VB.NET:
1. Private Type SYSTEM_POWER_STATUS
2.
3. ACLineStatus As Byte
4.
5. BatteryFlag As Byte
6.
7. BatteryLifePercent As Byte
8.
9. Reserved1 As Byte
10.
11. BatteryLifeTime As Long
12.
13. BatteryFullLifeTime As Long
14.
15. End Type
16.
17. Private Declare Function GetSystemPowerStatus Lib "kernel32" (lpSystemPowerStatus As SYSTEM_POWER_STATUS) As Long
18.
19. Private Sub Form_Paint()
20.
21. 'KPD-Team 2000
22.
23. 'URL: [url=http://www.allapi.net/]allapi.net[/url]
24.
25. 'E-Mail: [email]KPDTeam@Hotmail.com[/email]
26.
27. Dim SPS As SYSTEM_POWER_STATUS
28.
29. 'get the battery powerstatus
30.
31. GetSystemPowerStatus SPS
32.
33. Me.AutoRedraw = True
34.
35. 'show some information
36.
37. Select Case SPS.ACLineStatus
38.
39. Case 0
40.
41. Me.Print "AC power status: Offline"
42.
43. Case 1
44.
45. Me.Print "AC power status: OnLine"
46.
47. Case 2
48.
49. Me.Print "AC power status: Unknown"
50.
51. End Select
52.
53. Select Case SPS.BatteryFlag
54.
55. Case 1
56.
57. Me.Print "Battery charge status: High"
58.
59. Case 2
60.
61. Me.Print "Battery charge status: Low"
62.
63. Case 4
64.
65. Me.Print "Battery charge status: Critical"
66.
67. Case 8
68.
69. Me.Print "Battery charge status: Charging"
70.
71. Case 128
72.
73. Me.Print "Battery charge status: No system battery"
74.
75. Case 255
76.
77. Me.Print "Battery charge status: Unknown Status"
78.
79. End Select
80.
81. End Sub
Problem is, I've no idea as to how to go ahead and utilise this piece of code to get the desired battery level. Maybe... do I need to perhaps insert a label to display the Print statuses?
I've also realised it's the norm for people to post codes like this when it comes to VB.NET. But how do the coder, who uses the code, get the code working? (Definitely not copy-pasting everything, yeah?)
So I guess a general answer is enough. Pls help.
Thanks.