locked
How can I automatically my application when the power is low? RRS feed

  • Question

  • Hi!I got a problem when doing my work

    How can I automatically my application when the power is low?

    I want to start my application when the battery lift percent decent to 60%,or lower,(or something indicates the power status I can detect)

    How can I do it?

    Thanks!

    Saturday, August 28, 2010 2:00 AM

Answers

  • you can use 

    DWORD GetSystemPowerStatusEx2(
      PSYSTEM_POWER_STATUS_EX2 pSystemPowerStatusEx2,
      DWORD dwLen,
      BOOL fUpdate
    );

    API to know your battery status from your application. SYSTEM_POWER_STATUS_EX2 structure contains the battery information


    Vinoth.R http://vinoth-vinothblog.blogspot.com http://www.e-consystems.com
    • Marked as answer by warrentang Friday, September 3, 2010 2:51 AM
    Saturday, August 28, 2010 6:14 AM
  • Hi Tomatoyuki,

    Just use the SystemProperty .PowerBatteryStrength Managed API which is already in .NET CF.

    Christopher Fairbairn already explained here

     

    Hope it helps.


    If you find my post is helpful for you then mark as a answer.
    • Marked as answer by warrentang Friday, September 3, 2010 2:50 AM
    Saturday, August 28, 2010 8:33 AM
  • Rather than polling for the battery status (which can drain the battery faster), I'd recommend using the power notification message queue to notify you when the battery is low: http://msdn.microsoft.com/en-us/library/aa932427.aspx

    To your second question, yes you can adjust the battery level of your emulator: http://msdn.microsoft.com/en-us/library/bb630224.aspx#PowerStateEmulation

    -PaulH

    • Marked as answer by warrentang Friday, September 3, 2010 2:50 AM
    Tuesday, August 31, 2010 1:36 PM

All replies

  • you can use 

    DWORD GetSystemPowerStatusEx2(
      PSYSTEM_POWER_STATUS_EX2 pSystemPowerStatusEx2,
      DWORD dwLen,
      BOOL fUpdate
    );

    API to know your battery status from your application. SYSTEM_POWER_STATUS_EX2 structure contains the battery information


    Vinoth.R http://vinoth-vinothblog.blogspot.com http://www.e-consystems.com
    • Marked as answer by warrentang Friday, September 3, 2010 2:51 AM
    Saturday, August 28, 2010 6:14 AM
  • Hi Tomatoyuki,

    Just use the SystemProperty .PowerBatteryStrength Managed API which is already in .NET CF.

    Christopher Fairbairn already explained here

     

    Hope it helps.


    If you find my post is helpful for you then mark as a answer.
    • Marked as answer by warrentang Friday, September 3, 2010 2:50 AM
    Saturday, August 28, 2010 8:33 AM
  • Is it possible to test it in the emulator?

    I did not have a machine at hand for the moment

    Tuesday, August 31, 2010 12:21 PM
  • Rather than polling for the battery status (which can drain the battery faster), I'd recommend using the power notification message queue to notify you when the battery is low: http://msdn.microsoft.com/en-us/library/aa932427.aspx

    To your second question, yes you can adjust the battery level of your emulator: http://msdn.microsoft.com/en-us/library/bb630224.aspx#PowerStateEmulation

    -PaulH

    • Marked as answer by warrentang Friday, September 3, 2010 2:50 AM
    Tuesday, August 31, 2010 1:36 PM
  • Rather than polling for the battery status (which can drain the battery faster), I'd recommend using the power notification message queue to notify you when the battery is low: http://msdn.microsoft.com/en-us/library/aa932427.aspx

    To your second question, yes you can adjust the battery level of your emulator: http://msdn.microsoft.com/en-us/library/bb630224.aspx#PowerStateEmulation

    -PaulH


    Thank you very much!

    I'll try it.

    Friday, September 3, 2010 3:36 PM