title: ZeroMemory on PROCESSENTRY32 local variable?
body: <p>I needed to enumerate running processes and wondered for a while why my code wasn't working:</p>
  
  <pre><code>PROCESSENTRY32 ProcEntry;
  ZeroMemory (&amp;ProcEntry, sizeof (PROCESSENTRY32)); //problem
  ProcEntry.dwFlags = sizeof(PROCESSENTRY32);
  
  HANDLE Snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
  
  if (Snapshot == INVALID_HANDLE_VALUE)
      return false;
  
  if (Process32First(Snapshot, &amp;ProcEntry))
      ....
  </code></pre>
  
  <p>Problem was that Process32First always returned FALSE because of ERROR_BAD_LENGTH error. </p>
  
  <p>Once I removed ZeroMemory line, everything started working fine. So the question is, why ZeroMemory caused it? It should just fill memory at the address of X for Z bytes. I use it a lot for winapi pointer-like structures, this time I didnt realise its a local variable but that doesn't explain the problem or does it?</p>
  
  <p>Thanks,</p>
  
  <p>Kra</p>
  
  <p>EDIT: plus I found out code works fine only in Debug version, once I compile it as Release version, its bugged again :/</p>