title: Delphi6: Need to know is my application running in console session or remote desktop session
body: <p>My application is accessed from Remote Desktop clients from time to time.</p>
  
  <p>I want to know is it currently being used in console session or Remote Desktop session. If the latter is the case and the session is disconnected (user has disconnected but not logged off) it should redirect itself to console (like <code>tscon.exe 0 /dest:console</code> does on Windows XP).</p>
  
  <p>I'm currently running a shell script to achieve that (using <code>query.exe user</code> and <code>tscon.exe</code>) but would like my Delhi6 app do that instead.</p>