资源预览内容
第1页 / 共10页
第2页 / 共10页
第3页 / 共10页
第4页 / 共10页
第5页 / 共10页
第6页 / 共10页
第7页 / 共10页
第8页 / 共10页
第9页 / 共10页
第10页 / 共10页
亲,该文档总共10页全部预览完了,如果喜欢就下载吧!
资源描述
查看查看 PDA 电池使用量的实例电池使用量的实例作者:佚名 来源:乐博网收集 更新时间:2007-11-3 13:56:59 Get PDA Battery Info Summary: Using P/Invoke to get Battery Info. This technique is introduced in MSDN Library - January 2005 and this program is written based on the sample program of ms-help:/MS.MSDNQTR.2005JAN.1033/dncfhowto/html/getpowstat.htm Functions: This program get PDAs battery info- mation containing main battery lifetime, voltage,current,and backup battery info. 2005/3/17 Hesicong http:/dream-world.nease.net http:/blog.csdn.net/hesicong mailto:hesicongmail.sc.cninfo.net Imports System Imports System.Drawing Imports System.Collections Imports System.Windows.Forms Imports System.Data Imports System.Runtime.InteropServices Summary description for Form1. Public Class BatteryInfo Inherits System.Windows.Forms.Form Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Private mainMenu1 As System.Windows.Forms.MainMenu Public Sub New() Required for Windows Form Designer support InitializeComponent() End Sub New TODO: Add any constructor code after InitializeComponent call Clean up any resources being used. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) MyBase.Dispose(disposing) End Sub Dispose #Region “Windows Form Designer generated code“ Required method for Designer support - do not modify the contents of this method with the code editor. Friend WithEvents MenuItem4 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem5 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem7 As System.Windows.Forms.MenuItem Friend WithEvents Timer1 As System.Windows.Forms.Timer Friend WithEvents mnuAutoRefresh As System.Windows.Forms.MenuItem Friend WithEvents mnuAbout As System.Windows.Forms.MenuItem Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem Private Sub InitializeComponent() Me.mainMenu1 = New System.Windows.Forms.MainMenu Me.MenuItem4 = New System.Windows.Forms.MenuItem Me.MenuItem5 = New System.Windows.Forms.MenuItem Me.mnuAutoRefresh = New System.Windows.Forms.MenuItem Me.MenuItem7 = New System.Windows.Forms.MenuItem Me.mnuAbout = New System.Windows.Forms.MenuItem Me.TextBox1 = New System.Windows.Forms.TextBox Me.Timer1 = New System.Windows.Forms.Timer Me.MenuItem1 = New System.Windows.Forms.MenuItem mainMenu1 Me.mainMenu1.MenuItems.Add(Me.MenuItem4) Me.mainMenu1.MenuItems.Add(Me.mnuAbout) MenuItem4 Me.MenuItem4.MenuItems.Add(Me.MenuItem5) Me.MenuItem4.MenuItems.Add(Me.mnuAutoRefresh) Me.MenuItem4.MenuItems.Add(Me.MenuItem1) Me.MenuItem4.MenuItems.Add(Me.MenuItem7) Me.MenuItem4.Text = “Menu“ MenuItem5 Me.MenuItem5.Text = “Refresh“ mnuAutoRefresh Me.mnuAutoRefresh.Text = “AutoRefresh“ MenuItem7 Me.MenuItem7.Text = “End“ mnuAbout Me.mnuAbout.Text = “About“ TextBox1 Me.TextBox1.Location = New System.Drawing.Point(8, 8) Me.TextBox1.Multiline = True Me.TextBox1.ScrollBars = System.Windows.Forms.ScrollBars.Horizontal Me.TextBox1.Size = New System.Drawing.Size(224, 256) Me.TextBox1.Text = “ Timer1 Me.Timer1.Interval = 1000 MenuItem1 Me.MenuItem1.Text = “SetRefreshInterval“ BatteryInfo Me.Controls.Add(Me.TextBox1) Me.Menu = Me.mainMenu1 Me.Text = “BatteryInfo“ End Sub InitializeComponent #End Region The main entry point for the application. Shared Sub Main() Application.Run(New BatteryInfo) End Sub Main Public Class SYSTEM_POWER_STATUS_EX2 Public ACLineStatus As Byte Public BatteryFlag As Byte Public BatteryLifePercent As Byte Public Reserved1 As Byte Public BatteryLifeTime As System.UInt32 Public BatteryFullLifeTime As System.UInt32 Public Reserved2 As Byte Public BackupBatteryFlag As Byte Public BackupBatteryLifePercent As Byte Public Reserved3 As Byte Public BackupBatteryLifeTime As System.UInt32 Public BackupBatteryFullLifeTime As System.UInt32 Public BatteryVoltage As System.UInt32 Public BatteryCurrent As System.UInt32 Public BatteryAverageCurrent As System.UInt32 Public BatteryAverageInterval As System.UInt32 Public BatterymAHourConsumed As System.UInt32 Public BatteryTemperature As System.UInt32 Public BackupBatteryVoltage As System.UInt32 Public BatteryChemistry As Byte End Class SYSTEM_POWER_STATUS_EX2 Public Class SYSTEM_POWER_STATUS_EX Public ACLineStatus As Byte Public BatteryFlag As Byte Public BatteryLifePercent As Byte Public Reserved1 As Byte Public BatteryLifeTime As System.UInt32 Public BatteryFullLifeTime As System.UInt32 Public Reserved2 As Byte Public BackupBatteryFlag As Byte Public BackupBatteryLifePercent As Byte Public Reserved3 As Byte Public BackupBatteryLifeTime As System.UInt32 Public BackupBatteryFullLifeTime As System.UInt32 End Class SYSTEM_POWER_STATUS_EX _ Private Shared Function GetSystemPowerStatusEx(ByVal lpSystemPowerStatus As SYSTEM_POWER_STATUS_EX, ByVal fUpdate As Boolean) As System.UInt32 End Function _ Private Shared Function GetSystemPowerStatusEx2(ByVal lpSystemPowerStatus As SYSTEM_POWER_STATUS_EX2, ByVal dwLen As System.UInt32, ByVal fUpd
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号