How to get session name/number for a process using framework?

  • Thread starter Thread starter Microsoft Newsgroups
  • Start date Start date
M

Microsoft Newsgroups

Hi,

How do I get the session name and number of a process using the .NET
Framework? I'd like to display the same info as the TASKLIST command line
utility, but I cannot find this information as part of the Framework's
Process or ProcessModule classes.

Any ideas?

Thanks in advance,
Jim
 
As far as I know, there is no managed API that can give you this
information.
You will have to revet to Platform Invoke (P/Invoke) in order to get
this information.

You will have to use the extern command and DllExport attribute to
define the following functions (these are easy functions to translate):

ProcessIdToSessionId - To get the Session Id.
WTSQuerySessionInformation - To get the rest of the information.

Hope this helps,
Eran.
=======================================================
http://dotnetdebug.blogspot.com - Advanced .NET Debugging Blog
The place for WinDbg, SOS, live and post mortem debugging, tips, tricks
and fun stuff.
 
Back
Top