How to programaticaly switch from suspend mode to power on mode in windows mobile
-
Hi I want to make an application which can detect when my device is going to the sleep mode and then it will immediately on the device. I tried a little bit but in vain Let me show what i tried. Actually i am creating a thread which will try to detect when my device is going to the suspended state then it will try to power on .My logic is in this way but the functions i might be using may be a matter of concerned. Need guidance in that
In the WinAPI I am starting the thread
..
//Create a thread
m_hThread = CreateThread(NULL, 0, ThreadProc, NULL, 0, NULL);
...And in the thread function I am doing this
DWORD ThreadProc(LPVOID lpParameter)
{
LPWSTR pBuffer = NULL;
PDWORD pdwFlags = NULL ;
DWORD iState = NULL;
while(TRUE)
{
iState = GetSystemPowerState(pBuffer,sizeof(pBuffer),pdwFlags);
if(iState == POWER_STATE_SUSPEND)
{
SetSystemPowerState(NULL,POWER_STATE_ON,POWER_FORCE);
return 1;
}}
return 0;
}