有没有任何Win32 API在特定的时间唤醒已关闭的系统?我看到一个名为Autopower On的程序,它能够在指定的时间为系统供电.
解决方法
从网站获得了
the below post.任何身体都试过了吗?
在框架中没有什么,所以你必须要“PInvoke”一点.
您需要调用的API是CreateWaitableTimer和SetWaitableTimer.
以下是一个完整的(Q& D)样本,说明如何设置
系统从sleep / hibernate唤醒使用上面的Win32 API.
请注意,这里我设置的相对唤醒时间为300000000 nSecs.
这意味着电脑会醒来(假设他睡着了或者睡着了)
设置定时器后30秒内休眠.
有关SetWaitableTimer及其参数的详细信息,请参阅MSDN文档.
using System; using System.Runtime.InteropServices; using System.Windows.Forms; namespace Willys { class Program { [DllImport("kernel32.dll")] public static extern IntPtr CreateWaitableTimer(IntPtr lpTimerAttributes,bool bManualReset,string lpTimerName); [DllImport("kernel32.dll")] public static extern bool SetWaitableTimer(IntPtr hTimer,[In] ref long pDueTime,int lPeriod,IntPtr pfnCompletionRoutine,IntPtr lpArgToCompletionRoutine,bool fResume); [DllImport("kernel32",SetLastError = true,ExactSpelling = true)] public static extern Int32 WaitForSingleObject(IntPtr handle,uint milliseconds); static void Main() { SetWaitForWakeUpTime(); } static IntPtr handle; static void SetWaitForWakeUpTime() { long duetime = -300000000; // negative value,so a RELATIVE due time Console.WriteLine("{0:x}",duetime); handle = CreateWaitableTimer(IntPtr.Zero,true,"MyWaitabletimer"); SetWaitableTimer(handle,ref duetime,IntPtr.Zero,true); uint INFINITE = 0xFFFFFFFF; int ret = WaitForSingleObject(handle,INFINITE); MessageBox.Show("Wake up call"); } } }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。