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?
相关问题
- the application was unable to start correctly 0xc0
- Handle button click in another application
- win32 Python - pythoncom error - ImportError: No m
- How to prevent windows from accessing and detectin
- Getting the output from a process created by Creat
相关文章
- Why windows 64 still makes use of user32.dll etc?
- How do I get to see DbgPrint output from my kernel
- Can WM_NEXTDLGCTL be used with non-dialog windows?
- Windows EventLog: How fast are operations with it?
- Are resource files compiled as UNICODE or ANSI cod
- How can one batch file get the exit code of anothe
- user32 and kernel method list for C# [closed]
- Writing to the middle of the file (without ove
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:
Reading from the MSDN remarks section for WTSRegisterSessionNotification it says
So a neat solution might be to use OpenEvent to obtain a handle to the
Global\TermSrvReadyEvent
event then use WaitForSingleObject (with the handle obtained fromOpenEvent
and a sensible timeout) to wait for the terminal services to start (causing the handle to be signalled) before callingWTSRegisterSessionNotification
.Of course, you could probably also call
WTSRegisterSessionNotification
to begin with then, if it fails, useGetLastError
to see if it returnedRPC_S_INVALID_BINDING
and if so, do the above.