title: Parse string to LPCWSTR
body: <p>I am working with boost-filesystem to search all the files in a concrete path. 
  I also want to retrieve this file's creation data, last opening and last update so as I am working in Windows I need to use the <strong>GetFileTime</strong> (which requires a <strong>HANDLE</strong> that I will get by the <strong>CreateFile</strong> function.</p>
  
  <p>The point is that by boost filesystem I get a string such as </p>
  
  <blockquote>
    <p>string filename="C:\Users\MyUser\Desktop\PDN.pdf";</p>
  </blockquote>
  
  <p>and I need to convert this string to a LPCWSTR.</p>
  
  <p>Because of this I have done several tries which have all failed, for example:</p>
  
  <pre><code>HANDLE hFile = CreateFile((LPCWSTR)fileName.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, NULL);
  </code></pre>
  
  <p>But when doing this, it succeded:</p>
  
  <pre><code>HANDLE hFile = CreateFile(L"C:\\Users\\MyUSer\\Desktop\\PDN.pdf", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, NULL);
  </code></pre>
  
  <p>So my question is, how could I parse a string to a PWSTR using a string variable? 
  And if possible (I guess no), is there any function that will change the original path adding a slash where finds another slash?</p>
  
  <p>Thanks a lot</p>
  
  <p><strong>EDITED:
  This is the way I have done it after what I have read in here:</strong></p>
  
  <blockquote>
    <p>wstring fileFullPathWstring =
    winAPII.stringToWstring(iter->path().string());</p>
    
    <p>HANDLE hFile = CreateFile(fileFullPathWstring.c_str(), GENERIC_READ,
    FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, NULL);</p>
  </blockquote>
  
  <p>Using the function:</p>
  
  <pre><code>wstring WinAPIIteraction::stringToWstring(string stringName){
      int len;
      int slength = (int)stringName.length() + 1;
      len = MultiByteToWideChar(CP_ACP, 0, stringName.c_str(), slength, 0, 0);
      wchar_t* buf = new wchar_t[len];
      MultiByteToWideChar(CP_ACP, 0, stringName.c_str(), slength, buf, len);
      std::wstring r(buf);
      delete[] buf;
      return r;
  }
  </code></pre>