|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Searching the process listI want to iterate the process list looking at the processes running for the
current user. So I'm using: foreach (Process p in Process.GetProcesses()) { } But I can't see any method or property of the Process object p which tells me the username of the user running the process. p.StartInfo.UserName always seems to contain "". So how can I consider just the processes running under the current user ?
Show quote
"JezB" <jezbroadsw***@blueyonder.co.uk> wrote in message You can't use the Process class for this, you will have to use news:%23JnqGswUGHA.196@TK2MSFTNGP10.phx.gbl... |I want to iterate the process list looking at the processes running for the | current user. So I'm using: | | foreach (Process p in Process.GetProcesses()) | { | | } | | But I can't see any method or property of the Process object p which tells | me the username of the user running the process. p.StartInfo.UserName always | seems to contain "". | | So how can I consider just the processes running under the current user ? | System.Management and the WMI classes Win32_logonsession and Win32_Process, or you have to call the Terminal server API's (WTSEnumerateProcesses, WTSProcessInfo, WTSOpenServer, WTSCloseServer ....) and pass thSID obtained by WTSProcessInfo to LookupAccountSid using PInvoke. Willy. |
|||||||||||||||||||||||