mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Initial revision
svn path=/trunk/; revision=2400
This commit is contained in:
parent
d3b8d085e2
commit
d4d6b6dbf7
2 changed files with 63 additions and 0 deletions
21
reactos/apps/utils/ps/makefile
Normal file
21
reactos/apps/utils/ps/makefile
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
#
|
||||||
|
|
||||||
|
PATH_TO_TOP = ../..
|
||||||
|
|
||||||
|
TARGET_NORC = yes
|
||||||
|
|
||||||
|
TARGET_TYPE = program
|
||||||
|
|
||||||
|
TARGET_APPTYPE = console
|
||||||
|
|
||||||
|
TARGET_NAME = ps
|
||||||
|
|
||||||
|
TARGET_SDKLIBS = kernel32.a
|
||||||
|
|
||||||
|
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||||
|
|
||||||
|
include $(PATH_TO_TOP)/rules.mak
|
||||||
|
|
||||||
|
include $(TOOLS_PATH)/helper.mk
|
||||||
|
|
||||||
|
# EOF
|
42
reactos/apps/utils/ps/ps.cpp
Normal file
42
reactos/apps/utils/ps/ps.cpp
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
#include <windows.h>
|
||||||
|
#include <tlhelp32.h>
|
||||||
|
|
||||||
|
static char* title = " PID PARENT TIME NAME\n";
|
||||||
|
char buf[256];
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
HANDLE stdout = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
|
|
||||||
|
DWORD r;
|
||||||
|
WriteFile(stdout,title,lstrlen(title),&r,NULL);
|
||||||
|
|
||||||
|
HANDLE pl = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
|
||||||
|
|
||||||
|
PROCESSENTRY32 pe;
|
||||||
|
pe.dwSize = sizeof(PROCESSENTRY32);
|
||||||
|
pe.th32ParentProcessID = 0;
|
||||||
|
|
||||||
|
if(Process32First(pl,&pe)) do
|
||||||
|
{
|
||||||
|
HANDLE p =OpenProcess(PROCESS_QUERY_INFORMATION,FALSE,pe.th32ProcessID);
|
||||||
|
FILETIME cr;
|
||||||
|
FILETIME ex;
|
||||||
|
FILETIME kt;
|
||||||
|
FILETIME ut;
|
||||||
|
GetProcessTimes(p,&cr,&ex,&kt,&ut);
|
||||||
|
WORD fatdate;
|
||||||
|
WORD fattime;
|
||||||
|
FileTimeToDosDateTime(&cr,&fatdate,&fattime);
|
||||||
|
int hour = (fattime & 0xf800) >> 11;
|
||||||
|
int minute = (fattime & 0x07e0) >> 5;
|
||||||
|
|
||||||
|
wsprintf(buf,"%08X %08X %2d:%02d %s\n",pe.th32ProcessID,pe.th32ParentProcessID,hour,minute,pe.szExeFile);
|
||||||
|
WriteFile(stdout,buf,lstrlen(buf),&r,NULL);
|
||||||
|
CloseHandle(p);
|
||||||
|
pe.th32ParentProcessID = 0;
|
||||||
|
|
||||||
|
} while( Process32Next(pl,&pe));
|
||||||
|
|
||||||
|
CloseHandle(pl);
|
||||||
|
}
|
Loading…
Reference in a new issue