SystemParametersInfo() 设置无法激活屏幕保护程序,错误代码 = 329

发布于 2025-01-16 10:41:08 字数 1776 浏览 1 评论 0原文

在Windows登录过程中,我尝试激活屏幕保护程序:

ret = SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, state, NULL, 0);

当我使用GetLastError()时,它返回329;我在MSDN上找到:

如果机器进入省电模式或系统锁定状态,则会出现ERROR_OPERATION_IN_PROGRESS异常。

所以我改变了代码:

int loopNum = 10;
do{
    ret = SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, state, NULL, 0);
    if(!ret){
loginfo("[set_screensave_active] set screensave active status to 1 failed, gle = %d",Getlasterror());
}
    Sleep(1000);
}
while(loopNum--);

我确信Windows登录需要很短的时间。

当我登录 Windows 时会触发此代码。有时会报错329,10次循环全部失败!

日志如下:

2022-03-08 08:58:33 [12120/14436] [WARN] [set_screensave_active] 将屏幕保存活动状态设置为 1 失败,gle 329

2022-03-08 08:58:34 [12120/ 14436] [警告] [set_screensave_active] 设置屏幕保护将活动状态设置为 1 失败,gle 329

2022-03-08 08:58:35 [12120/14436] [警告] [set_screensave_active] 将屏幕保存活动状态设置为 1 失败,gle 329

2022-03-08 08:58:36 [ 12120/14436] [警告] [set_screensave_active] 将屏幕保存活动状态设置为 1 失败,gle 329

2022-03-08 08:58:37 [12120/14436] [警告] [set_screensave_active] 将屏幕保存活动状态设置为 1 失败,gle 329

2022-03-08 08 :58:38 [12120/14436] [警告] [set_screensave_active] 将屏幕保护活动状态设置为 1 失败,gle 329

2022-03-08 08:58:39 [12120/14436] [警告] [set_screensave_active] 将屏幕保护活动状态设置为 1 失败,角329

2022-03-08 08:58:40 [12120/14436] [WARN] [set_screensave_active] 将屏幕保护活动状态设置为 1 失败,gle 329

2022-03-08 08:58:41 [12120/14436] [WARN] [set_screensave_active] 设置屏幕保护活动状态为 1 失败,gle 329

2022-03-08 08:58:42 [12120/14436] [WARN] [set_screensave_active] 将屏幕保护活动状态设置为1失败,gle 329

在8:58:33中,我开始登录Win10。并且,在8中: 58:35,我登录了Win10。每秒调用一次API SystemParametersInfo,持续十秒。 8:58:36之后,系统不再处于锁定状态。但 SystemParametersInfo 也返回错误代码 329。

During the Windows login process, I try to activate the screensaver:

ret = SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, state, NULL, 0);

When I use GetLastError(), it returns 329; I found on MSDN:

If the machine has entered power saving mode or system lock state, an ERROR_OPERATION_IN_PROGRESS exception occurs.

So I change the code:

int loopNum = 10;
do{
    ret = SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, state, NULL, 0);
    if(!ret){
loginfo("[set_screensave_active] set screensave active status to 1 failed, gle = %d",Getlasterror());
}
    Sleep(1000);
}
while(loopNum--);

I'm sure that Windows login takes a short time.

This code is triggered when I login to Windows. Sometimes the error 329 is reported, all 10 times the loop fails!

The logs are as follows:

2022-03-08 08:58:33 [12120/14436] [WARN] [set_screensave_active] set screensave active status to 1 failed, gle 329

2022-03-08 08:58:34 [12120/14436] [WARN] [set_screensave_active] set screensave active status to 1 failed, gle 329

2022-03-08 08:58:35 [12120/14436] [WARN] [set_screensave_active] set screensave active status to 1 failed, gle 329

2022-03-08 08:58:36 [12120/14436] [WARN] [set_screensave_active] set screensave active status to 1 failed, gle 329

2022-03-08 08:58:37 [12120/14436] [WARN] [set_screensave_active] set screensave active status to 1 failed, gle 329

2022-03-08 08:58:38 [12120/14436] [WARN] [set_screensave_active] set screensave active status to 1 failed, gle 329

2022-03-08 08:58:39 [12120/14436] [WARN] [set_screensave_active] set screensave active status to 1 failed, gle 329

2022-03-08 08:58:40 [12120/14436] [WARN] [set_screensave_active] set screensave active status to 1 failed, gle 329

2022-03-08 08:58:41 [12120/14436] [WARN] [set_screensave_active] set screensave active status to 1 failed, gle 329

2022-03-08 08:58:42 [12120/14436] [WARN] [set_screensave_active] set screensave active status to 1 failed, gle 329

In 8:58:33, I began to logon the Win10.And, In 8:58:35, I logined the Win10.The API SystemParametersInfo is called every second for ten seconds. After 8:58:36, the system was not in lock states. But SystemParametersInfo also return error code 329.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文