public static bool ListThread(FThreadInfoCollection threads, int processId) { threads.Clear(); IntPtr hSnap = RKernel32.CreateToolhelp32Snapshot(ETh32cs.SnapThread, processId); if (RApi.IsValidHandle(hSnap)) { SThreadEntry32 te32 = new SThreadEntry32(); te32.dwSize = Marshal.SizeOf(te32); bool next = RKernel32.Thread32First(hSnap, ref te32); while (next) { if (te32.th32OwnerProcessID == processId) { FThreadInfo thread = new FThreadInfo(); thread.ProcessID = te32.th32OwnerProcessID; thread.Id = te32.th32ThreadID; thread.Flags = te32.dwFlags; thread.BasePri = te32.tpBasePri; thread.DeltaPri = te32.tpDeltaPri; thread.Usage = te32.cntUsage; threads.Push(thread); } next = RKernel32.Thread32Next(hSnap, ref te32); } RKernel32.CloseHandle(hSnap); return(true); } return(false); }