I've been trying to get process list and came up with this piece of code:
#include <iostream>
#include <string>
#include <windows.h>
#include <tlhelp32.h>
using namespace std;
int main()
{
HANDLE hndl = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
if( hndl )
{
bool ff;
LPPROCESSENTRY32 proces;
proces->dwSize = sizeof( LPPROCESSENTRY32 );
ff = Process32First(hndl,proces);
if(ff)
{
cout << proces->szExeFile << endl;
while(ff = Process32Next(hndl,proces))
{
ff = Process32Next(hndl,proces);
cout << proces->szExeFile << endl;
}
}
else
{
cout << "Error :(" << endl;
}
}
CloseHandle(hndl);
system("pause");
return 0;
}
It compiles good but when I run it it shows and Error and app just breaks.
So if anyone knows a better way to display a list of processes with their handle-s and ids please give me an example that will work on Windows 98.


Sign In
Create Account


Back to top









