C#:如何唤醒已经关机的系统?
发布时间:2020-12-15 03:45:56 所属栏目:百科 来源:网络整理
导读:有没有任何Win32 API在特定的时间唤醒已关闭的系统?我看到一个名为Autopower On的程序,它能够在指定的时间为系统供电. 解决方法 从网站获得了 the below post.任何身体都试过了吗? 在框架中没有什么,所以你必须要“PInvoke”一点. 您需要调用的API是Create
|
有没有任何Win32 API在特定的时间唤醒已关闭的系统?我看到一个名为Autopower On的程序,它能够在指定的时间为系统供电.
解决方法
从网站获得了
the below post.任何身体都试过了吗?
在框架中没有什么,所以你必须要“PInvoke”一点. 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");
}
}
}
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
