WTSRegisterSessionNotification 有时在 XP home 启动时不起作用

编程入门 行业动态 更新时间:2024-10-23 21:25:03
本文介绍了WTSRegisterSessionNotification 有时在 XP home 启动时不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我正在使用函数/消息来检查工作站是否被锁定.现在我的应用程序位于启动文件夹中.它在 XP pro 上运行没有任何问题,但是由于我在 XP home 上使用该程序,WTSRegisterSessionNotification 在启动时大约有 50% 的时间失败,但是当系统已经启动时它永远不会失败.知道为什么会发生这种情况吗?

I'm using the function/message to check if the workstation is locked. Now my application is in the startup folder. It has worked without any problems on XP pro, but since I'm using the program on XP home WTSRegisterSessionNotification fails about 50% of the time on startup, but it never fails when the system is already booted up. Any idea why this could happen?

推荐答案

在 XP 上,服务在后台启动并且不会阻止启动或登录.在您调用 WTSRegisterSessionNotification 时,termsrv 服务很可能没有运行.

On XP, services start in the background and do not block boot or logon. The termsrv service is most likely not running by the time you call WTSRegisterSessionNotification.

您可以通过以下方式检查服务是否正在运行:

You can check if the service is running by:

// Error handling omitted for brevity
SC_HANDLE scm = OpenSCManager(NULL, NULL, GENERIC_READ);
SC_HANDLE svc = OpenService(scm, L"TermSrv", SERVICE_QUERY_STATUS);
SERVICE_STATUS status;
QueryServiceStatus(svc, &status);
if (status.dwCurrentSTate != SERVICE_RUNNING) {
    // Try to start, wait and try again, etc.
}

CloseServiceHandle(svc);
CloseServiceHandle(scm);

这篇关于WTSRegisterSessionNotification 有时在 XP home 启动时不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-26 00:58:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1126853.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:启动时   不起作用   WTSRegisterSessionNotification   XP   home

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!