////保證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
