Start komputera z uśpienia

0

Witam
Mam pytanie dotyczące programowego przywrócenia komputera ze stanu uśpienia. Wiem, że z hibernacji się nie da, lecz czy da się z uśpienia? Muszę tak "postawić komputer", aby startował o określonej godzinie, wykonywał określoną czynność i np. usypiał się ponownie. Po ustalonym czasie czynność powtarzał. Chciałbym to zrobić najlepiej programowo, lecz nie wiem jak go wybudzić.
Dziękuję z góry za wszelką pomoc.

0

Tutaj probowales?

0

Dokladnie, dwie funkcyjki z kernel32.
Najprostszy przyklad tu:

http://stackoverflow.com/questions/4061844/c-how-to-wake-up-system-which-has-been-shutdown

0

Dzięki bardzo za pomoc.
Działa coś takiego:

 class Clock :  DispatcherObject
    {
        [DllImport("kernel32.dll")]
        static extern IntPtr CreateWaitableTimer(IntPtr lpTimerAttributes, bool bManualReset, string lpTimerName);
        [DllImport("kernel32.dll")]
        static extern bool SetWaitableTimer(IntPtr hTimer, [In] ref long pDueTime, int lPeriod, IntPtr pfnCompletionRoutine, IntPtr lpArgToCompletionRoutine, bool fResume);
        [DllImport("kernel32.dll")]
        static extern bool CancelWaitableTimer(IntPtr hTimer);
        [DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
        static extern Int32 WaitForSingleObject(IntPtr handle, uint milliseconds);
        [DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Auto)]
        [return: MarshalAs(UnmanagedType.Bool)]
        static extern bool CloseHandle(IntPtr hObject);
        IntPtr handle = IntPtr.Zero;

        public event EventHandler Alarm;

        public void SetAlarm(DateTime time)
        {
            long duetime = time.ToFileTimeUtc();
            handle = CreateWaitableTimer(IntPtr.Zero, true, "AlarmClockTimer");
            SetWaitableTimer(handle, ref duetime, 0, IntPtr.Zero, IntPtr.Zero, true);
            (new Action(Sleep)).BeginInvoke(null, null);
        }

        void Sleep()
        {
            uint INFINITE = 0xFFFFFFFF;
            int ret = WaitForSingleObject(handle, INFINITE);
            CloseHandle(handle);
            Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
            {
                EventHandler temp = Alarm;
                if (temp != null) temp(this, EventArgs.Empty);
            }));
        }

        public void CancelAlarm()
        {
            try
            {
                if (handle != IntPtr.Zero)
                {
                    CancelWaitableTimer(handle);
                    CloseHandle(handle);
                    handle = IntPtr.Zero;
                }
            }
            catch
            {
                throw new Exception("Błąd wyłączenia alarmu");
            }
        }
    }

1 użytkowników online, w tym zalogowanych: 0, gości: 1