title: GetOpenFileNameW results in FNERR_INVALIDFILENAME, or CDERR_INITIALIZATION if I call GetOpenFileNameA
body: <p>Here's the code using <code>GetOpenFileNameW</code>:</p>
  
  <pre><code>import core.sys.windows.windows;
  import std.stdio, std.string, std.utf;
  
  pragma(lib, "comdlg32");
  
  // Fill in some missing holes in core.sys.windows.windows.
  extern (Windows) DWORD CommDlgExtendedError();
  enum OFN_FILEMUSTEXIST = 0x001000;
  
  void main()
  {
      auto buf = new wchar[1024];
  
      OPENFILENAMEW ofn;
      ofn.lStructSize = ofn.sizeof;
      ofn.lpstrFile = buf.ptr;
      ofn.nMaxFile = buf.length;
      ofn.lpstrInitialDir = null;
      ofn.Flags = OFN_FILEMUSTEXIST;
  
      BOOL retval = GetOpenFileNameW(&amp;ofn);
      if (retval == 0) {
          // Get 0x3002 for W and 0x0002 for A. ( http://msdn.microsoft.com/en-us/library/windows/desktop/ms646916(v=vs.85).aspx )
          throw new Exception(format("GetOpenFileName failure: 0x%04X.", CommDlgExtendedError()));
      }
  
      writeln(buf);
  }
  </code></pre>
  
  <p>This results in <code>FNERR_INVALIDFILENAME</code>, but I don't see any non-optional strings that I haven't filled in. And here's the code (only differences shown) for <code>GetOpenFileNameA</code>:</p>
  
  <pre><code>auto buf = new char[1024];
  
  OPENFILENAMEA ofn;
  // ...
  BOOL retval = GetOpenFileNameA(&amp;ofn);
  </code></pre>
  
  <p>This results in <code>CDERR_INITIALIZATION</code>, and the only elaboration MSDN gives me is </p>
  
  <pre><code>The common dialog box function failed during initialization. 
  This error often occurs when sufficient memory is not available.
  </code></pre>
  
  <p>This is on Windows 7 64 bit, DMD v2.059.</p>