2

So it seems there are many questions asking how to detect when a system enters Connected Standby, but I'm looking to actually cause it to happen.

Reason is, simply calling the SetPowerState(Sleep) methods in C# no longer works if Connected Standby is enabled (doesn't do a darn thing whatsoever), and my app that puts the system to sleep therefore no longer works.

Note: I don't want to wake up the system, I want to do the equivalent of clicking Start -> Power -> Sleep.

Tsaukpaetra
  • 579
  • 5
  • 26

2 Answers2

3

So... Apparently, because there is no "Sleep" when S0 Low Power Idle is available, that is the reason traditional methods of putting a computer to sleep doesn't work: The option isn't available.

Essentially, the Sleep command from the power menu simply turns off the display, which triggers the rest of Connected Standby.

So, existing code to tell the Display off will achieve the same affect, something like so:

[DllImport("user32.dll")]  
private static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);   

void doStandby()
{
    //Turn off the monitor
    SendMessage(0xFFFF,0x112,0xF170,2);
} 

Of course, there needs to be some code to determine which sleep method is appropriate to your device, but that is discussed elsewhere.

Tsaukpaetra
  • 579
  • 5
  • 26
0

This question has already been answered here: https://stackoverflow.com/a/37032188/2277323

Do not do:

Process.Start("rundll32.exe", "powrprof.dll,SetSuspendState 0,1,0");

as it will invoke undefined behavior and might put the computer into hibernation instead. (Thank you CherryDT).

Community
  • 1
  • 1
Hoss
  • 400
  • 3
  • 8
  • I will check back on this, but from my recollection this exact thing is what I'm saying doesn't work on systems with S0 support. – Tsaukpaetra May 11 '16 at 16:53