How to create a file with UNICODE path on Windows with C++

放肆的年华 提交于 2021-01-27 20:46:55

问题


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.


回答1:


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




回答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.



来源:https://stackoverflow.com/questions/10149505/how-to-create-a-file-with-unicode-path-on-windows-with-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!