• Question

  • hello i am very new with mobile developing ,

    i have windows ce device i develped c# App my customer wants that app to be auto run once device is docked on the charging station .
    cann you help


    Friday, August 5, 2011 7:55 AM


  • Hello,


    As far as I know, we can use State and Notifications Broker to get the system state changed. First we need to registry our application to system, and then if the state change we can get this event in out application. You can get the sample in this How Do I: Automatically Start an Application on a System State Change?


    The State and Notifications Broker only keep watch on the subkeys under HKEY_LOCAL_MACHINE\System\State\Hardware\, but these value is different from different devices, this can be set by OEM. If the OEM did not add the value for battery charge, we could not use this way.


    On the other hand, we can use  GetSystemPowerStatusEx API to get the SYSTEM_POWER_STATUS_EX struct, in this struct we can see if the battery flag is BATTERY_FLAG_CHARGING. You can follow this document to use this function HOWTO: Get the Device Power Status, but in this way, we need to call this API again and again. It is not automatic.


    I hope my suggestions can help you to solve this problem.


    Best regards,


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Jesse Jiang Thursday, August 11, 2011 8:44 AM
    Monday, August 8, 2011 11:23 AM