////保证config.txt从本DLL目录位置读取 //获取DLL自身所在路径(此处包括DLL文件名) char DllPath[MAX_PATH] = { 0 }; GetModuleFileNameA((HINSTANCE)&__ImageBase, DllPath, _countof(DllPath));
//截取DLL所在目录(去掉DLL文件名) char drive[_MAX_DRIVE]; char dir[_MAX_DIR]; char fname[_MAX_FNAME]; char ext[_MAX_EXT]; _splitpath(DllPath, drive, dir, fname, ext);
//字符串拼接 strcat(dir, "config.txt");
参考文章:https://blog.csdn.net/hust_bochu_xuchao/article/details/53281721