Vero, System Diagnostics Process ha una moltitudine di metodi e proprietà ma non c'è semplicemente un .UserName o simile. Per questo serve ancora un accesso vecchia maniera ad un paio di API, ma non aspettarti di avere comunque una lista completa di tutti gli Owners di processo. Vedrai che riceverai parecchi "Accesso negato", in ogni caso prova questo :
Codice:
Public Declare Function OpenProcessToken Lib "advapi32.dll" Alias "OpenProcessToken" (ByVal ProcessHandle As IntPtr, ByVal DesiredAccess As UInt32, ByRef TokenHandle As IntPtr) As Boolean
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As IntPtr) As Boolean
Public Const TOKEN_QUERY As UInteger = &H8
Codice:
Dim ph As IntPtr = IntPtr.Zero
For Each P As Process In Process.GetProcesses
Try
OpenProcessToken(P.Handle, TOKEN_QUERY, ph)
Dim WI As New Security.Principal.WindowsIdentity(ph)
ListBox1.Items.Add(P.ProcessName & " - " & WI.Name)
Catch ex As Exception
ListBox1.Items.Add(P.ProcessName & " - " & ex.Message)
Finally
If ph <> IntPtr.Zero Then CloseHandle(ph)
End Try
Next