2

I am wondering which Win32 API call is creating the files with UNICODE path. Just to make sure, I am not talking about the content here only the file path. I would appreciate if somebody would hit me with an MSDN url, my google fu failed this time.

Thanks a million in advance.

Istvan
  • 7,500
  • 9
  • 59
  • 109
  • Er, `CreateFile`? What Win32 API related to I/O _doesn't_ support Unicode? – ildjarn Apr 13 '12 at 23:21
  • 1
    Windows has supported unicode since NT 3.1 http://support.microsoft.com/kb/99884 – EdChum Apr 13 '12 at 23:23
  • I think the phrase you're looking for with MSDN is [UNC](http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx). – Ken White Apr 13 '12 at 23:25
  • I found the CreateFileW() function which does what I need. Thanks guys. – Istvan Apr 13 '12 at 23:45
  • Your app should be compiled with UNICODE defined and then you get the native Unicode API rather than the naff legacy ANSI wrapper to the true API – David Heffernan Apr 14 '12 at 07:56

2 Answers2

3

See CreateFile msdn link: http://msdn.microsoft.com/en-us/library/windows/desktop/aa363858%28v=vs.85%29.aspx, if you pass a unicode string to the lpFileName parameter then the unicode version of CreateFile will be used.

Also you need to open the file in binary mode see this discussion on msdn forum: http://social.msdn.microsoft.com/forums/en-US/vclanguage/thread/71fa98ca-e757-4099-8f7f-fefcfe645298 which points to this msdn article: http://msdn.microsoft.com/en-us/library/c4cy2b8e%28vs.71%29.aspx

EdChum
  • 376,765
  • 198
  • 813
  • 562
-2

The principal tag on this question is "c++" not "windows. Now, unless that was just a all-too-common cheat to get a windows api question in front of a larger - mostly unrelated - audience, the answer should be slightly relevant to c++.

As such, in a C++ app, there are a number of std:: specializations that can take wchar_t. wofstream for example.

Chris Becke
  • 34,244
  • 12
  • 79
  • 148