传入参数:string name
string fileName;
fileName.resize(MAX_PATH);
::GetModuleFileName(NULL, const_cast<char*>(fileName.c_str()), MAX_PATH);
fileName = fileName.substr(static_cast<string::size_type>(0), fileName.rfind('\\'));
fileName += static_cast<string>("\\") + name;
使用BYTE数组
static char dl_file [] = "alarm\\DL.log";
char pathname [MAX_PATH_LEN];
GetModuleFileName (NULL, pathname, sizeof(pathname));
strcpy (strrchr (pathname, '\\')+1, dl_file);
标签:文件,cast,MAX,位置,fileName,获取,pathname,PATH,static From: https://www.cnblogs.com/xiaoxiaoshi/p/17483690.html