Alessandro Annini
Alessandro Annini

Reputation: 1551

How to wake up from Hibernation at a given day/time?

I need to wake up a hibernated laptop at a given time every day.

Should I use pinvoke? If yes? which one? How?

Upvotes: 1

Views: 691

Answers (2)

Chris S
Chris S

Reputation: 65426

You can wake the computer up from sleep, I'm not sure about hibernate. This example shows you how to do it. In short you use these two imports:

[DllImport("kernel32.dll")]
public static extern SafeWaitHandle CreateWaitableTimer(IntPtr lpTimerAttributes, bool bManualReset, string lpTimerName);

[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetWaitableTimer(SafeWaitHandle hTimer, [In] ref long pDueTime, int lPeriod, IntPtr pfnCompletionRoutine, IntPtr lpArgToCompletionRoutine, bool fResume);

I've only tested it on Windows Vista and 7, these may not be available on XP.

Upvotes: 2

Ben Everard
Ben Everard

Reputation: 13804

I know it's VB and not C#, but take a look at this example, it does require that your motherboard meets certain requirements.

Upvotes: 1

Related Questions