exported stubs for Process32First, Process32Next and CreateToolhelp32Snapshot created.
[reactos.git] / reactos / apps / utils / ps / ps.cpp
1 #include <windows.h>
2 #include <tlhelp32.h>
3
4 static char* title = " PID PARENT TIME NAME\n";
5 char buf[256];
6
7 int main()
8 {
9 HANDLE stdout = GetStdHandle(STD_OUTPUT_HANDLE);
10
11 DWORD r;
12 WriteFile(stdout,title,lstrlen(title),&r,NULL);
13
14 HANDLE pl = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
15
16 PROCESSENTRY32 pe;
17 pe.dwSize = sizeof(PROCESSENTRY32);
18 pe.th32ParentProcessID = 0;
19
20 if(Process32First(pl,&pe)) do
21 {
22 HANDLE p =OpenProcess(PROCESS_QUERY_INFORMATION,FALSE,pe.th32ProcessID);
23 FILETIME cr;
24 FILETIME ex;
25 FILETIME kt;
26 FILETIME ut;
27 GetProcessTimes(p,&cr,&ex,&kt,&ut);
28 WORD fatdate;
29 WORD fattime;
30 FileTimeToDosDateTime(&cr,&fatdate,&fattime);
31 int hour = (fattime & 0xf800) >> 11;
32 int minute = (fattime & 0x07e0) >> 5;
33
34 wsprintf(buf,"%08X %08X %2d:%02d %s\n",pe.th32ProcessID,pe.th32ParentProcessID,hour,minute,pe.szExeFile);
35 WriteFile(stdout,buf,lstrlen(buf),&r,NULL);
36 CloseHandle(p);
37 pe.th32ParentProcessID = 0;
38
39 } while( Process32Next(pl,&pe));
40
41 CloseHandle(pl);
42 }
43 /*
44 WINBOOL
45 STDCALL
46 FileTimeToDosDateTime(
47 CONST FILETIME *lpFileTime,
48 LPWORD lpFatDate,
49 LPWORD lpFatTime
50 );
51 */