获取文件位置

传入参数: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);

posted @ 2023-06-15 17:58  中班小小石  阅读(17)  评论(0)    收藏  举报