none
Disabling sleep mode with registry setings

    Question

  • Hi,

    I want to disable sleep while the application is active. I tried to change the registry key values with the following lines:

    if(enabled)
    {
    dwData = 120;
    }
    //if(RegSetValueEx(HKEY_LOCAL_MACHINE, _T("System\\CurrentControlSet\\Control\\Power\\WakeupPowerOff"), 0, REG_EXPAND_SZ, (LPBYTE)SleepModeString, (DWORD)(lstrlen(SleepModeString)+1)*sizeof(TCHAR)))
    if(RegSetValueEx(HKEY_LOCAL_MACHINE, _T("System\\CurrentControlSet\\Control\\Power\\Timeouts\\BattSuspendTimeout"), 0, REG_DWORD, (LPBYTE)&dwData, sizeof(DWORD)))
    {
    return FALSE;
    }

    but it doesn't affect the registry value. Beside this I don't know exactly which key has to be set in order to disable sleep mode.

    I would appreciate any hint.

    Thanks,

    Niko
    Wednesday, October 29, 2008 2:58 PM

Answers

  •  

    Hi Niko

     

    There is no API to prevent the device from sleeping directly. But you can call a function called SystemIdleTimerReset to reset the timer that controls the sleeping.

     

    The following guide will show you how to use the SystemIdleTimerReset function in more details:
    How to: Prevent Automatic Power Down

    http://msdn.microsoft.com/en-us/library/aa458873.aspx

    Regards

    Chunsheng Tang

     

    Sunday, November 02, 2008 4:09 AM
    Moderator
  •  

    You may want to just run your application in unattened mode.  the application will then continue to run while the screen is turned off, that is much friendlier to the battery.
    Sunday, November 02, 2008 6:51 AM

All replies

  •  

    Hi Niko

     

    There is no API to prevent the device from sleeping directly. But you can call a function called SystemIdleTimerReset to reset the timer that controls the sleeping.

     

    The following guide will show you how to use the SystemIdleTimerReset function in more details:
    How to: Prevent Automatic Power Down

    http://msdn.microsoft.com/en-us/library/aa458873.aspx

    Regards

    Chunsheng Tang

     

    Sunday, November 02, 2008 4:09 AM
    Moderator
  •  

    You may want to just run your application in unattened mode.  the application will then continue to run while the screen is turned off, that is much friendlier to the battery.
    Sunday, November 02, 2008 6:51 AM
  • Do you mean this application will run in the suspended state as well ?
    Monday, November 03, 2008 2:55 AM