mfc 获取当前exe的路径

xiaoxiao2021-02-28  98

1、API

path:char*指针, 200长度

GetModuleFileNameA(NUL,  path, 200);

(strrchr (path, '\\') )[1] = 0; //去除最后的的文件名和\\

2、API

//参考http://blog.csdn.net/xjujun/article/details/8054990和http://blog.csdn.net/muscle_cui/article/details/4053100 CString CDlgBMTabControl::GetExePath( ) {   CString strExePath;   GetModuleFileName(NULL, strExePath.GetBuffer(MAX_PATH), MAX_PATH);   strExePath.ReleaseBuffer();   strExePath = strExePath.Left(strExePath.ReverseFind(_T('\\')));  //去除最后的文件名 return strExePath;   } 

以上获取函数一样,去掉最后一个“\\”不一样

转载请注明原文地址: https://www.6miu.com/read-30115.html

最新回复(0)