Reputation: 725
I have Windows 8 and the Power options are too hard to get to so i want to make a little app to replicate Power tab.
What i can't do is find a way to make windows Sleep. In windows 8 when the PC is Sleeping it is completely stopped and if you press a key it goes to Lock Screen instantaneously without the boot screen.
How can I accomplish that?
UPDATE: Or if it is possible to get a list of all power options available. ie: if hibernation is allowed...
I am using rundll32.exe powrprof.dll,SetSuspendState 0,1,0
to sleep PC now but it wakes very slow.
Upvotes: 0
Views: 550
Reputation: 22106
This should help you.
I think you can lock the pc and then put it to sleep.
To lock the screen:
[DllImport("user32.dll", SetLastError = true)]
static extern bool LockWorkStation();
For entering sleep mode:
Application.SetSuspendState(PowerState.Suspend, false, false);
Upvotes: 2
Reputation: 121599
If you're using Win-RT, then you should use the "suspension manager":
http://msdn.microsoft.com/en-us/library/windows/apps/hh986968.aspx
http://dotnet.dzone.com/articles/process-lifetime-management
Upvotes: 0