SetSuspendState() API 在 Win8 中永不返回 [英] SetSuspendState() API never returns in Win8

查看:34
本文介绍了SetSuspendState() API 在 Win8 中永不返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我解释一下我的问题陈述:

Let me explain my problem statement:

在我的 VC++ 项目中,我想插入一个逻辑,以编程方式将我的系统 (Windows 8) 发送到睡眠状态 &恢复回来.

In my VC++ project I want to insert a logic to send my system (Windows 8) to Sleep state programatically & resume back.

我就是这样做的(复制代码片段)::

I'm doing it like this (Copying the code snippet) ::

int wait = 100;
LARGE_INTEGER WaitTime;
    WaitTime.QuadPart = wait;
    WaitTime.QuadPart *= -10000000;

HANDLE hTimer = CreateWaitableTimer(NULL, FALSE, NULL);
        if(0 == SetWaitableTimer(hTimer, &WaitTime, 0, NULL, NULL, TRUE))
        {
            res = false;
            return res;
        }
        if(0 == SetSuspendState(FALSE, FALSE, FALSE))
        {
            res = false;
            return res;
        }

系统即将进入睡眠状态(显示器正在关闭).
在这里,我想在 SetSuspendState() API 调用后从睡眠状态恢复.但我看到 SetSuspendState() 调用根本没有返回.控制将在此 SetSuspendState() 调用本身上触发 &不会回来.

The system is going to sleep (monitor is getting turned off).
Here, I want to resume back from sleep state after SetSuspendState() API call. But I see the SetSuspendState() call is not at all returning. The control would be struck at the this SetSuspendState() call itself & doesn't return back.

但是,如果我强行使系统恢复供电,我会看到它恢复但函数SetSuspendState()"不会在我的代码中返回.

However, if I forcefully bring the system back to power , I see it come back but the function "SetSuspendState()" doesn't return back in my code.

谁能帮我弄清楚为什么 SetSuspendState() 没有返回 &如何解决这个问题.提前致谢.

Can anyone please help me to figure out why is the SetSuspendState() not returning back & how to fix this problem. Thanks in advance.

PS:我使用 VS 远程调试器机制来实现这种睡眠状态.

PS: I'm using VS remote debugger mechanism to achieve this sleep state.

推荐答案

我认为对 SetSuspendState 的调用会导致远程调试服务器关闭.当您调用 SetSuspendState 时,系统开始关闭,这涉及通知所有应用程序系统正在关闭.当这种情况发生时,这些应用程序预计会终止.因此,您可能会失去与远程调试器的连接.

I imagine that the call to SetSuspendState results in the remote debug server being shutdown. When you call SetSuspendState the system starts a shutdown, and that involves notifying all applications that the system is going down. When that happens, those applications are expected to terminate. So you can expect to lose your connection to the remote debugger.

这篇关于SetSuspendState() API 在 Win8 中永不返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆