2 * ReactOS ps - process list console viewer
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 static char* title = " PID PARENT TIME NAME\n";
32 HANDLE stdout = GetStdHandle(STD_OUTPUT_HANDLE);
34 WriteFile(stdout, title, lstrlen(title), &r, NULL);
35 pl = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
36 pe.dwSize = sizeof(PROCESSENTRY32);
37 pe.th32ParentProcessID = 0;
39 if (Process32First(pl, &pe)) do {
44 HANDLE p = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pe.th32ProcessID);
49 GetProcessTimes(p, &cr, &ex, &kt, &ut);
50 FileTimeToDosDateTime(&cr, &fatdate, &fattime);
51 hour = (fattime & 0xf800) >> 11;
52 minute = (fattime & 0x07e0) >> 5;
53 wsprintf(buf,"%08X %08X %2d:%02d %s\n", pe.th32ProcessID, pe.th32ParentProcessID, hour, minute, pe.szExeFile);
54 WriteFile(stdout, buf, lstrlen(buf), &r, NULL);
56 pe.th32ParentProcessID = 0;
57 } while (Process32Next(pl, &pe));
64 FileTimeToDosDateTime(
65 CONST FILETIME *lpFileTime,