title: Very strange GetOpenFileName problem
body: <p>I seem to be having a very strange problem with GetOpenFileName.</p>
  
  <p>It errors for no apparent reason, however, if I call <code>CommDlgExtendedError()</code> in the error check, the error never happens in the first place.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>#include &lt;windows.h&gt;
  int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
  {
      OPENFILENAME fm;
      char flnm[MAX_PATH];
      ZeroMemory(&amp;fm, sizeof(fm));
  
      fm.lStructSize = sizeof(OPENFILENAME);
      fm.hwndOwner = NULL;
      fm.lpstrFilter = "Text Files (*.txt)\0*.txt\0";
      fm.lpstrFile = flnm;
      fm.nMaxFile = MAX_PATH;
      fm.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
      fm.lpstrDefExt = "";
  
      if(!GetOpenFileNameA(&amp;fm))
      {
          MessageBoxA(NULL, "failed! :(", NULL, NULL);
      }
  
      return 0;
  }
  </code></pre>
  
  <p>What's shown? "failed! :(" </p>
  
  <p>If I remove this check, I do see a file dialog. However, it doesn't work, and the filename box is pre-filled with random junk.</p>
  
  <p>If I change to:</p>
  
  <pre><code>if(!GetOpenFileNameA(&amp;fm))
  {
      DWORD dwErr = CommDlgExtendedError();
      MessageBoxA(NULL, "failed! :(", NULL, NULL);
  }
  </code></pre>
  
  <p>"failed! :(" is NOT shown. The file dialog shows and performs without issue.</p>
  
  <p>What is going on!?!?</p>