This is common in windows, often, leaving a file.
This function is generally used:
size_t wcstombs ( char *mbstr, const wchar_t *WCSTR, size_t count);
Mbstr
The address of a sequence of multibyte characters.
Wcstr
The address of a sequence of wide characters.
Count
The maximum number of bytes that can is stored in the multibyte output string.
Locale
The locale to use.
Here is a test I wrote, which was changed according to the project:
1#include <windows.h>2#include <string.h>3#include <stdio.h>4#include <stdlib.h>5#include <boost/filesystem.hpp>6 7 namespaceBFS =Boost::filesystem;8 9 Ten BOOLGet_path (Char*file_name,size_t size) { One A - CharOwnpth[max_path]; - thehmodule hmodule = GetModuleHandle (NULL);//Would contain exe Path,when passing NULL to GetModuleHandle, it returns handle of EXE itself - if(Hmodule! =NULL) - { -GetModuleFileNameA (hmodule,ownpth, MAX_PATH);// + } - Else +ownpth[0]=0; A at BFS::p ath Iic_file (ownpth); -Iic_file = Iic_file.parent_path ()/"DLP_USB.IIC";//For releaseing - - if( !Bfs::is_regular_file (iic_file)) - { -printf"\r\nerror,open 68013 IIc file fail\r\n"); in return false ; - } to + - wcstombs (File_name,iic_file.c_str (), size); the * //memcpy (File_name,iic_file.c_str (), byte_count); $ Panax Notoginseng return true; - the } + A intMain () { the + Chariic_file[ +]; - $ if(Get_path (Iic_file, +)){ $ -printf"true\n"); - } the - return 0;Wuyi}
References
Http://msdn.microsoft.com/en-us/library/5d7tc9zw.aspx
http://blog.163.com/tianshi_17th/blog/static/4856418920085209414977/
wchar_t* to char* under Windows