mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
ps did not require a lot from C++, so now it doesn't require it at all.
svn path=/trunk/; revision=3934
This commit is contained in:
parent
7a48c7fcf2
commit
661896dfde
3 changed files with 70 additions and 53 deletions
|
@ -12,8 +12,6 @@ TARGET_NAME = ps
|
||||||
|
|
||||||
TARGET_SDKLIBS = kernel32.a
|
TARGET_SDKLIBS = kernel32.a
|
||||||
|
|
||||||
TARGET_GCCLIBS = th32 stdc++
|
|
||||||
|
|
||||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||||
|
|
||||||
include $(PATH_TO_TOP)/rules.mak
|
include $(PATH_TO_TOP)/rules.mak
|
||||||
|
|
70
reactos/apps/utils/ps/ps.c
Normal file
70
reactos/apps/utils/ps/ps.c
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
/* $Id: ps.c,v 1.1 2003/01/04 18:36:28 robd Exp $
|
||||||
|
*
|
||||||
|
* ReactOS ps - process list console viewer
|
||||||
|
*
|
||||||
|
* ps.c
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <tlhelp32.h>
|
||||||
|
|
||||||
|
static char* title = " PID PARENT TIME NAME\n";
|
||||||
|
char buf[256];
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
DWORD r;
|
||||||
|
HANDLE pl;
|
||||||
|
PROCESSENTRY32 pe;
|
||||||
|
HANDLE stdout = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
|
|
||||||
|
WriteFile(stdout, title, lstrlen(title), &r, NULL);
|
||||||
|
pl = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
||||||
|
pe.dwSize = sizeof(PROCESSENTRY32);
|
||||||
|
pe.th32ParentProcessID = 0;
|
||||||
|
|
||||||
|
if (Process32First(pl, &pe)) do {
|
||||||
|
int hour;
|
||||||
|
int minute;
|
||||||
|
WORD fatdate;
|
||||||
|
WORD fattime;
|
||||||
|
HANDLE p = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pe.th32ProcessID);
|
||||||
|
FILETIME cr;
|
||||||
|
FILETIME ex;
|
||||||
|
FILETIME kt;
|
||||||
|
FILETIME ut;
|
||||||
|
GetProcessTimes(p, &cr, &ex, &kt, &ut);
|
||||||
|
FileTimeToDosDateTime(&cr, &fatdate, &fattime);
|
||||||
|
hour = (fattime & 0xf800) >> 11;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
FileTimeToDosDateTime(
|
||||||
|
CONST FILETIME *lpFileTime,
|
||||||
|
LPWORD lpFatDate,
|
||||||
|
LPWORD lpFatTime
|
||||||
|
);
|
||||||
|
*/
|
|
@ -1,51 +0,0 @@
|
||||||
#include <windows.h>
|
|
||||||
#include <tlhelp32.h>
|
|
||||||
|
|
||||||
static char* title = " PID PARENT TIME NAME\n";
|
|
||||||
char buf[256];
|
|
||||||
|
|
||||||
int 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);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
WINBOOL
|
|
||||||
STDCALL
|
|
||||||
FileTimeToDosDateTime(
|
|
||||||
CONST FILETIME *lpFileTime,
|
|
||||||
LPWORD lpFatDate,
|
|
||||||
LPWORD lpFatTime
|
|
||||||
);
|
|
||||||
*/
|
|
Loading…
Reference in a new issue