新写了一个闹钟小程序到时间可以播放音乐,但是我想让将电脑处在待机状态以节约电和减少电脑磨损。时间到了程序把电脑唤醒然后播放音乐,网上查了一下没有什么程序能实现这个功能,只有windows自带的计划任务可以实现这个功能。
请问还有其他办法吗?

解决方案 »

  1.   

    当电脑处于待机、关机的情况下,没办法靠程序来唤醒的呀如果单纯只为了做闹钟的话,可以通过BIOS设置每天定时开机,开机了后,就好办了~你的程序到点了就能响起音乐了~我每天就是这样靠电脑放歌起床的哈
      

  2.   

    using System;
    using System.Runtime.InteropServices;
    using Microsoft.Win32.SafeHandles;
    using System.Threading;
    using System.ComponentModel;namespace ConsoleApplication1 {
        class Program {
            [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);        static void Main(string[] args) {
                SetWaitForWakeUpTime();
            }        static void SetWaitForWakeUpTime() {
                DateTime utc = DateTime.Now.AddMinutes(1);
                long duetime = utc.ToFileTime();            using (SafeWaitHandle handle = CreateWaitableTimer(IntPtr.Zero, true, "MyWaitabletimer")) {
                    if (SetWaitableTimer(handle, ref duetime, 0, IntPtr.Zero, IntPtr.Zero, true)) {
                        using (EventWaitHandle wh = new EventWaitHandle(false, EventResetMode.AutoReset)) {
                            wh.SafeWaitHandle = handle;
                            wh.WaitOne();
                        }
                    } else {
                        throw new Win32Exception(Marshal.GetLastWin32Error());
                    }
                }            // You could make it a recursive call here, setting it to 1 hours time or similar
                Console.WriteLine("Wake up call");
                Console.ReadLine();
            }
        }
    }
      

  3.   


    就是楼主要的~,DateTime utc = DateTime.Now.AddMinutes(1);
    这里加的时间就是wake up 回调的延时
      

  4.   

    thank you very much !