简体   繁体   中英

WTSEnumerateProcesses and Terminal Services Service

My Windows Service occasionally reports the following error when calling WTSEnumerateProcesses() :

The binding handle is invalid.

This is caused, I suspect, by the unavailability of the Terminal Services Service, even though I have the Terminal Services Service registered as a dependent service for my service.

I believe that even though the Terminal Services Service is running, it has not completed initialisation (or is shutting down) and is not capable of servicing any requests, resulting in the error.

I noticed the following in the reference documentation for WTSRegisterSessionNotification() :

When the Global\\TermSrvReadyEvent global event is set, all dependent services have started and this function can be successfully called.

This does not appear in the documentation for WTSEnumerateProcesses() , but does it equally apply? Meaning an attempt to OpenEvent() on Global\\\\TermSrvReadyEvent would indicate that the Terminal Services Service is actually available?


Platforms: Windows XP, Windows Vista and Windows 7

You definitely want to OpenEvent(SYNCHRONIZE, false, L"Global\\\\TermSrvReadyEvent") and wait for it.

All WTS* functions call the terminal services service (now known as the remote desktop services service) via RPC under the hood of the C API ( see the runtime interface protocol ).

In contrary to what c00000fd experienced, I never encountered issues with standard user accounts and said event object on Windows 7 and above.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM