Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
649 views
in Technique[技术] by (71.8m points)

winapi - 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

For the session id, use ProcessIdToSessionId().


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...