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