Hi I've done that little taskmanager :
Code:
#include <windows.h>
#include <psapi.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.c>
int Kill(int pID)
{
int ret;
HANDLE hProcess=OpenProcess(PROCESS_ALL_ACCESS,
TRUE,pID);
if(hProcess==NULL)
{
return 1;
}
ret = !TerminateProcess(hProcess,0);
CloseHandle(hProcess);
return ret;
}
char * GetProcessName(DWORD processID ,char * szProcessName, DWORD bufsiz)
{
HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ,
0, processID );
szProcessName[0]='\0';
if (NULL != hProcess )
{
HMODULE hMod;
DWORD cbNeeded;
if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod),
&cbNeeded) )
{
GetModuleBaseName( hProcess, hMod, szProcessName,
bufsiz );
}
else return NULL;
}
else return NULL;
CloseHandle( hProcess );
return szProcessName;
}
int main(int argc, char**argv)
{
int volte=0;
char scelta;
char szProcessName[MAX_PATH];
DWORD aProcesses[1024], cbNeeded, cProcesses;
unsigned int i;
if ( GetVersion() > 0x80000000 )
{
printf("Funziono solo su XP!!\n");
goto fine;
}
inizio:
volte = volte + 1;
if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) )
return 1;
cProcesses = cbNeeded / sizeof(DWORD);
printf("\n");
printf(" [");
textcolor(LIGHTRED);
printf("Bianconiglio's TaskManager");
textcolor(WHITE);
printf("]\n");
printf(" [--Processi in Esecuzione--]\n");
printf(" [ Aggiornamento numero ");
textcolor(YELLOW);
printf("%d",volte);
textcolor(WHITE);
printf("/2 ]\n");
printf("\n");
for ( i = 0; i < cProcesses; ++i )
{
GetProcessName(aProcesses[i],szProcessName,MAX_PATH);
if ((szProcessName!=NULL)||(szProcessName!="")||(szProcessName!="\0"));
printf(" %s\n", szProcessName);
}
printf("\n");
printf(" [---Invio per Aggiornare---]\n");
printf(" [ ]\n");
printf(" [-Possibilita di 2 refresh-]\n");
printf("\n");
scelta = getchar();
if (volte > 1)
goto fine;
else while (scelta='a' || 'A')
goto inizio;
fine:
system("pause");
return 0;
}
(if u want to compile it, u have to use psapi lib)
the problem is that the output is not perfect :
as u can see in the attached image, there are some empty lines
it've tried to avoid it with
Code:
if ((szProcessName!=NULL)||(szProcessName!="")||(szProcessName!="\0"));
but there is nothing to do...
suggestions ?