Is my App Running on Citrix XenDesktop/XenApp?

How do you programmatically determine if an application is running in a session accessed over a remoting protocol (i.e. ICA aka HDX or RDP)? It may be Citrix’ strategy to completely hide the fact that a session is remoted - which makes sense in many ways - but in some cases developers simply need to know in order to optimize their applications. It is surprisingly difficult to find official documentation about this. Here is what you need to know.
Citrix/Terminal Services/Remote Desktop Services



