Recent

Author Topic: How to ensure process in running in console session  (Read 5053 times)

Robert Gilland

  • Full Member
  • ***
  • Posts: 160
How to ensure process in running in console session
« on: July 27, 2012, 08:23:57 am »
we have an windows XP embedded machine ( single session workstation )

This should only allow 1 session however when
Using WTSGetActiveConsoleSessionId this returns a value of 2.
How can this be?
I am logging in via RDP starting a process.
This process is returning my session = 2.
So I then cancelling it. becasue this is a non console session id.
Since the workstaion only takes 1 session.

How to ensure that my task is running on the systems consolesession.

Kind Regards,

RObert.

Robert Gilland

  • Full Member
  • ***
  • Posts: 160
Re: How to ensure process in running in console session
« Reply #1 on: July 31, 2012, 01:01:15 am »
OK I have solved it.

After searching everywhere and finding nothing.

Step 1. Call kernel32.dll -> WTSGetActiveConsoleSessionId  to get console session id.
Step 2. use jedi library function jwsclToken.JwGetProcessLogonSession to get process session id.
Step 3. if( console session = process session ) or ( process session is zero )then VICTORY!!!!

2 days of in depth searching to get the result. %)



BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: How to ensure process in running in console session
« Reply #2 on: July 31, 2012, 08:17:34 am »
Glad you solved it and that you documented the result here to save the next unfortunate soul with this problem 2 days of searching.

Note: if you don't get any useful responses here, you can also try asking in the FPC mailing list (or Lazarus mailing list).
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

 

TinyPortal © 2005-2018