gpt4 book ai didi

c# - 如何在给定的日期/时间从休眠状态中醒来?

转载 作者:可可西里 更新时间:2023-11-01 11:40:42 26 4
gpt4 key购买 nike

我需要每天在指定时间唤醒休眠的笔记本电脑。

我应该使用 pinvoke 吗?如是?哪一个?怎么办?

最佳答案

您可以将计算机从 sleep 中唤醒,我不确定是否休眠。 This example向您展示如何操作。简而言之,您使用这两个导入:

[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);

我只在 Windows Vista 和 7 上测试过,这些在 XP 上可能不可用。

关于c# - 如何在给定的日期/时间从休眠状态中醒来?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1700364/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com