You can easily enumerate processes in most OSs by using the well known
toolhelp functions. Unfortunately the toolhelp functions don't work in NT4.
So here's a function which enumerates processes and works well in all OSs.
type TDAProcess = arrayofrecord id : dword; // process id exeFile : string; // exe file (9x = full path; nt = name only) session : dword; // session id sid : string; // user sid end;
functionEnumProcesses : TDAProcess;
// Example: functionGetProcessSessionId(processId: dword) : dword; vari1 : integer; pl : TDAProcess; begin result := 0; pl := EnumProcesses; fori1 := 0tohigh(pl) do ifpl[i1].id = processIdthenbegin result := pl[i1].session; break; end; end;