Ana Betts
Ana Betts

Reputation: 74682

How do I get the SID / session of an arbitrary process?

I'm writing a program to enumerate through processes, and I want to find out the SID/user ID and session of which the specified process is running under (i.e. i have a PID/handle to process, I want the SID and session it's running under). Any clues?

Upvotes: 2

Views: 8550

Answers (2)

Ana Betts
Ana Betts

Reputation: 74682

WTSEnumerateProcesses works like gangbusters here:

http://msdn.microsoft.com/en-us/library/aa383831%28VS.85%29.aspx

Upvotes: 3

Carlos A. Ibarra
Carlos A. Ibarra

Reputation: 6142

For the SID, call OpenProcess to get the handle, then pass the handle to GetSecurityInfo().

For the session id, use ProcessIdToSessionId().

Upvotes: 7

Related Questions