if ((int)handle > 0)
{
try
{
PROCESSENTRY32 peCurrent;
PROCESSENTRY32 pe32 = new PROCESSENTRY32();
//Get byte array to pass to the API calls
byte[] peBytes = pe32.ToByteArray();
//Get the first process
int retval = Process32First(handle, peBytes);
while(retval == 1)
{
//Convert bytes to the class
peCurrent = new PROCESSENTRY32(peBytes);
//New instance
Process proc = new Process(new IntPtr((int)peCurrent.PID), peCurrent.Name, (int)peCurrent.ThreadCount, (int)peCurrent.BaseAddress);