Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There is an API function that lets you determine whether a specific user session is displayed on the console (locally) or via one the the remoting protocols Citrix ICA (nowadays called HDX) or Microsoft RDP.</p> <p>Call <a href="http://msdn.microsoft.com/en-us/library/aa383838%28VS.85%29.aspx" rel="nofollow noreferrer">WTSQuerySessionInformation</a> with 3rd parameter set to <a href="http://msdn.microsoft.com/en-us/library/aa383861%28VS.85%29.aspx" rel="nofollow noreferrer">WTSClientProtocolType</a>. The function returns:</p> <ul> <li>0 for console sessions</li> <li>1 for ICA sessions</li> <li>2 for RDP sessions</li> </ul> <p>Interestingly the return value of 1 is not documented as <code>WTS_PROTOCOL_TYPE_ICA</code> on MSDN (second link above) any more, but as "This value is retained for legacy purposes.".</p> <p><strong>Update:</strong></p> <p><em>XenDesktop</em> sessions cannot be detected with <code>WTSQuerySessionInformation</code> (it returns 0, meaning Console). If you want a universal solution:</p> <ul> <li>Call <code>WTSQuerySessionInformation</code>. If that returns 1 or 2 (ICA or RDP), you are done.</li> <li>If <code>WTSQuerySessionInformation</code> returns 0 (Console), dynamically load <code>wfapi.dll</code> and get the address of <code>WFGetActiveProtocol</code></li> <li>Call <code>WFGetActiveProtocol</code> with a parameter of <code>WF_CURRENT_SESSION</code>, which is defined as ((DWORD)-1)</li> <li>The return value of <code>WFGetActiveProtocol</code> is the session type. It should be either 0 (Console) or 1 (ICA)</li> </ul> <p>I have described the process in detail <a href="http://helgeklein.com/blog/2014/08/app-running-citrix-xendesktopxenapp/" rel="nofollow noreferrer">here</a> along with a C++ code sample and a working compiled tool that returns the current session's remoting protocol type.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload