title: CreateFile fails (ERROR_FILE_NOT_FOUND) when file has latin characters
body: <p>I'm trying to open files in C, but I'm getting problems when the file has latin characters in Windows.</p>
  
  <p>This code</p>
  
  <pre><code>hFile = CreateFileW(ws, // file to be opened
  GENERIC_READ, // open for reading
  FILE_SHARE_READ, // share for reading
  NULL, // default security
  OPEN_EXISTING, // open existing file only
  FILE_ATTRIBUTE_NORMAL |FILE_ATTRIBUTE_ARCHIVE | SECURITY_IMPERSONATION,
  // normal file archive and impersonate client
  NULL); // no attr. template
  
  if(hFile == INVALID_HANDLE_VALUE)
      printf("Could not open %ls file, error %d\n", ws, GetLastError());
  else
      printf("File's HANDLE is OK!\n");
  
  // when finished, close the file handle
  CloseHandle(hFile);
  </code></pre>
  
  <p>works perfectly when the file doesn't have any strange character but fails with error 2 (ERROR_FILE_NOT_FOUND) when it does.</p>
  
  <p>--</p>
  
  <p>For example, with this file:</p>
  
  <pre><code>C:\Documents and Settings\Administrador\Escritorio\hola.mp3
  </code></pre>
  
  <p>the output is</p>
  
  <pre><code>File's HANDLE is OK!
  </code></pre>
  
  <p>But with this file:</p>
  
  <pre><code>C:\Documents and Settings\Administrador\Escritorio\holá.mp3
  </code></pre>
  
  <p>the output is</p>
  
  <pre><code>Could not open C:\Documents and Settings\Administrador\Escritorio\holá.mp3 file, error 2
  </code></pre>
  
  <p>Both files exist on that location.</p>
  
  <p>--</p>
  
  <p>This is the initialisation of ws:</p>
  
  <pre><code>char* filename;
  wchar_t  ws[256];
  
  // I get the filename from the SDK I am using (Cycling'74 Max SDK)
  filename = (atom_getsym(argv))-&gt;s_name;
  // and convert it to UTF16
  AnsiToUnicode16(filename, ws, 256);
  </code></pre>
  
  <p><code>AnsiToUnicode16</code> is using <code>MultiByteToWideChar</code> to do the conversion.</p>
  
  <p>--</p>
  
  <p>When I use FindFirstFile() to iterate thru the files of the folder I get this results:</p>
  
  <ul>
  <li>Next file name is hola.mp3.</li>
  <li>Next file name is hol□.mp3.</li>
  </ul>
  
  <p>I have no idea about how to let it know that <code>hol□.mp3</code> should be <code>holá.mp3</code>.</p>
  
  <p>BTW, if the folder is the one which has the accent, the FindFirstFile() fails.</p>