日期:2014-05-17 浏览次数:20969 次
[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); /// <summary> /// 设置唤醒时间 /// </summary> private void SetWaitForWakeUpTime(DateTime OnTime) { DateTime utc = OnTime; 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; Application.SetSuspendState(PowerState.Hibernate, true, false); wh.WaitOne(); } } else { throw new Win32Exception(Marshal.GetLastWin32Error()); } } }
------解决方案--------------------
定时开机
1.bios设置
2.网络唤醒(大部分主板上网卡支持,同样在bios设置打开,不少宽带路由也可以如此唤醒某台电脑)
3。bios设置一通电就开电脑,这样有不少带数据线的ups有定时开机功能,这时也可开电脑
------解决方案--------------------
现在几乎所有主板bios都支持普通的usb口鼠标键盘消息就能唤醒电脑的。
------解决方案--------------------
1.开启bios网络唤醒功能;
2.在被控机的供电系统接入电控定时器;
3.采购定时器,按照厂商提供的API实现控制程序;
4.在被控机(或其他计算机)用软件设定定时器开启时间;