CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
英特尔®游戏设计大赛100美元现金周周送 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  VB >  基础类

如何获取电源状态信息?

楼主xsyun()2003-11-01 08:58:00 在 VB / 基础类 提问

如何获取电源状态信息? 问题点数:100、回复次数:2Top

1 楼pandengzhe(无为之为 之 混迹苍生)回复于 2003-11-01 09:07:12 得分 95

1、SysInfo.ocx控件  
  2、GetSystemPowerStatus  
   
  Option   Explicit  
   
  Private   Declare   Function   GetSystemPowerStatus   Lib   "kernel32"   (lpSystemPowerStatus   As   SYSTEM_POWER_STATUS)   As   Long  
   
  Private   Type   SYSTEM_POWER_STATUS  
          ACLineStatus   As   Byte   'Checks   to   see   if   your   connected   to   the   walloutlet   or   not  
          BatteryFlag   As   Byte   'Battery   status  
          BatteryLifePercent   As   Byte   'precentage   left  
          Reserved1   As   Byte   'Dont   use  
          BatteryLifeTime   As   Long   'Total   time   left   of   your   battery  
          BatteryFullLifeTime   As   Long   'Total   UPtime   of   your   battery  
  End   Type  
   
  Private   SysPower   As   SYSTEM_POWER_STATUS  
  'End   Declares  
   
  Private   Sub   Form_Load()  
   
          'Property   Get   ACLineStatus()   As   Integer  
          'Returns   a   value   that   indicates   whether   or   not   the   system   is   using   AC   power.  
          'Property   Get   BatteryFullLifeTime()   As   Long  
          'Returns   a   value   that   indicates   the   full   charge   life   of   the   battery.  
          'Property   Get   BatteryLifePercent()   As   Integer  
          'Returns   the   percentage   of   full   battery   power   remaining.  
          'Property   Get   BatteryLifeTime()   As   Long  
          'Returns   a   value   that   indicates   the   remaining   life   of   the   battery.  
          'Property   Get   BatteryFlag()   As   Integer  
          'Returns   a   value   that   indicates   the   status   of   the   battery's   charge.  
   
          GetSystemPowerStatus   SysPower  
   
          Label1.Caption   =   Format$(SysPower.BatteryLifePercent   /   100,   "Percent")  
   
          Label2.Caption   =   Format$(Val(SysPower.BatteryLifeTime)   *   (1   /   3600),   "##.0")   &   "   Hours"  
   
          Label3.Caption   =   Format$(Val(SysPower.BatteryFullLifeTime)   *   (1   /   3600),   "##.0")  
   
          'Label4.Caption   =   SysPower.ACLineStatus  
          If   SysPower.ACLineStatus   =   0   Then  
                  Label4.Caption   =   "NON   AC   POWER"  
          ElseIf   SysPower.ACLineStatus   =   1   Then  
                  Label4.Caption   =   "AC   POWER"  
          ElseIf   SysPower.ACLineStatus   =   2   Then  
                  Label4.Caption   =   "UNKNOWN   AC   POWER"  
          End   If  
   
          'Label5.Caption   =   SysPower.BatteryFlag  
          If   SysPower.BatteryFlag   =   1   Then  
                  Label5.Caption   =   "HIGH"  
          ElseIf   SysPower.BatteryFlag   =   2   Then  
                  Label5.Caption   =   "LOW"  
          ElseIf   SysPower.BatteryFlag   =   4   Then  
                  Label5.Caption   =   "CRITICAL"  
          ElseIf   SysPower.BatteryFlag   =   128   Then  
                  Label5.Caption   =   "NO   BATTERY"  
          ElseIf   SysPower.BatteryFlag   =   255   Then  
                  Label5.Caption   =   "UNKNOWN"  
          End   If  
   
  End   Sub  
  Top

2 楼taosihai1only(无招胜有招)回复于 2003-11-01 14:38:02 得分 5

up  
  Top

相关问题

  • 键盘状态的获取
  • 获取光驱状态
  • 例子代码:获取Windows系统信息(各种版本信息、平台、状态等等)
  • 100分求助:各位高手,我想获取打印机的状态信息,该如何处理啊!
  • 高手请教!linux怎样通过pid获取进程信息,如:进程名、进程状态等?
  • 如何获取鼠标状态 !!!
  • UNIX下怎样获取进程状态?
  • 如何获取mediaplayer的停播状态
  • 如果获取线程当前状态
  • 如何获取套接字的状态??

关键词

  • 信息
  • aclinestatus
  • batterylifepercent
  • batteryfulllifetime
  • 获取电源状态信息
  • battery
  • power
  • status
  • full
  • total

得分解答快速导航

  • 帖主:xsyun
  • pandengzhe
  • taosihai1only

相关链接

  • Visual Basic类图书
  • Visual Basic类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo