Terminal services APIs not loading in time on Windows XP and ways to bypass it

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hello:
Im writing a service application that needs to enumerate all current user sessions (and obtain their session IDs) and later see what processes are running for what session. Im using the
<span style="font-size:x-small WTSEnumerateSessions() API, as well as <span style="font-size:x-small
WTSQuerySessionInformation() to obtain a session specific information. Unfortunately those WTS APIs are very unreliable. Let me explain...<br/>
<br/>
On a Windows Xp machine with Fast User Switching turned off, or on an XP machine joined to a domain, those APIs are not immediately available. They may fail with the
<span style="font-size:x-small RPC_S_INVALID_BINDING (or 1702) error code for as long as
several minutes after the Windows XP boots up and my service starts. I could not find any official documentation explaining how to handle such limitation. The one available via a search engine is to wait for the terminal services service to
load up, which is of course possible, but becomes a *MAJOR* pain in the a** to implement.<br/>
<br/>
So if someone could answer the following Id appreciate it:<br/>
<br/>
1. Are there any alternative APIs to work with session specific data (that are more reliable that those WTS ones)? I mostly need to see current sessions on the machine, get a user name and session status. Also enumerate processes with session IDs for each process.
(I know that this is possible, since GINA or a log-in screen, can do all that way before the terminal services load up.)<br/>
<br/>
2. Is there a 100% guaratee that WTS-class APIs (such as WTSEnumerateSessions(), WTSQuerySessionInformation() and
<span style="font:12px/15px "Segoe UI","Lucida Grande",Verdana,Arial,Helvetica,sans-serif; text-align:left; color:#2a2a2a; text-transform:none; text-indent:0px; letter-spacing:normal; word-spacing:0px; white-space:normal; orphans:2; widows:2; background-color:#ffffff
WTSEnumerateProcesses()) will load up *before* my service starts up on
*any* version of Windows Vista/Windows 7 machine?<br/>
<br/>
Please note *bofore* and *any* stipulations that a VERY important.

View the full article
 
Back
Top