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;
}
以上获取函数一样,去掉最后一个“\\”不一样