SetSuspendState

  • Thread starter Thread starter Nitin Kapoor
  • Start date Start date
N

Nitin Kapoor

Dear All,

I am trying to do a run a simple program where by if user clicks the
button the system goes into suspension and then the

system get awaked.i know this is a very common question and i have
serached various thread for where i am going wrong but

have not been able to find out the answer.Below is my code explaing
what i am doing.in the buttons click functionality i have

this code.


//Timer Stuff
HANDLE hTimer = NULL;
LARGE_INTEGER liDueTime;
// 10 Seconds Timer
liDueTime.QuadPart= -100000;

// Create a waitable timer.Copied from MSDN
hTimer = CreateWaitableTimer(NULL, FALSE, "WaitableTimer");
if (!hTimer)
{
printf("CreateWaitableTimer failed (%d)\n", GetLastError());

}

// Set a timer to wait for 10 seconds.
if (!SetWaitableTimer(hTimer, &liDueTime, 0, NULL, NULL, TRUE))
{
printf("SetWaitableTimer failed (%d)\n", GetLastError());

}


// I even tried SetSystemPowerOff with the required Powers it
desires but it does the same thing as setsuspendstate

//sends the computer into suspension but doesnot bring it back from
standby.


// SetSystemPowerState(FALSE,TRUE);

SetSuspendState(FALSE,FALSE, FALSE);

CancelWaitableTimer(hTimer);
//To Bring Back the Computer to live state,wake the monitor
SetThreadExecutionState(ES_DISPLAY_REQUIRED);


but this code doesnt do the necessary stuff for me , it only sends the
computer to standby stage but doesnt bring ti back.
i have tried all thing cant figure out a reason why its not bring the
system out of reboot.

I also tried a Microsoft application which does the same thing and it
works fine so probably the way i am giving the timer is incorrect or
some thing .
if any one has done this before please let me know where am i wrong.

Anyone?

Thanks & Regards,

Nitin Kapoor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top