Sapphire Battery Utility使您可以讀取當(dāng)前電池的電量級(jí)別,并且告知用戶設(shè)備是否需要充電。這可以使用戶能夠提前做好計(jì)劃,對(duì)設(shè)備進(jìn)行充電。
Sapphire Battery Utility allows you to read the current battery level and inform the user whether the device will require recharging. This will ensure the user can plan ahead and keep the device charged up.
電池電量不是無(wú)限的。使您的用戶避免在急需用電的時(shí)候卻發(fā)現(xiàn)電池沒(méi)電是非常重要的.
實(shí)例代碼: 該操作是如此簡(jiǎn)單的,您只需在您的程序中聲明相應(yīng)的DLL函數(shù),然后在您需要的地方調(diào)用即可。下面是一個(gè)關(guān)于如何在VB.NET中讀取電池電量等級(jí)的示例。
Dim lPercent As Long
lPercent = BatteryPercent()
If lPercent = 255 Then
lblBattery.Text = " Battery Charging...."
Else
lblBattery.Text = " Battery level is " & lPercent & " %"
End If
Battery power is not infinite. It is important to ensure that your users don’t find themselves without any battery power right when they need it the most.

Click here to view a third party article on how to use the Sapphire Battery Utility
Sample Code
Implementation couldn’t be easier, simply declare the DLL function as a function within your application and call it as though you wrote it yourself. Here’s a sample how to ready the battery level within VB.NET.
Dim lPercent As Long
lPercent = BatteryPercent()
If lPercent = 255 Then
lblBattery.Text = " Battery Charging...."
Else
lblBattery.Text = " Battery level is " & lPercent & " %"
End If