title: Process ID function getting error "ERROR_NO_MORE_FILES"
body: <p>Im trying to get the ID from a process using the function below, however GetLastError keeps returning ERROR_NO_MORE_FILES so it never gets the chance to iterate through all the processes. Im not sure whats causing this. Any ideas? Also as a test i was passing in the param as "notepad.exe"</p>
  
  <pre><code>int GetProcID(string ProcName){
      PROCESSENTRY32 PE32;
      HANDLE ProcSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
  
      PE32.dwSize = sizeof(PROCESSENTRY32);
  
      if(!Process32First(ProcSnapshot,&amp;PE32))
          return 0;
      else
          if(PE32.szExeFile == ProcName)
              return PE32.th32ProcessID;
          else
          {
              while(GetLastError() != ERROR_NO_MORE_FILES){
                  Process32Next(ProcSnapshot,&amp;PE32);
                      if(PE32.szExeFile == ProcName)
                          return PE32.th32ProcessID;
              }
              return 0;
          }
  }
  </code></pre>