[MFC]获得程序所在路径

来源:互联网 发布:java序列化和反序列化 编辑:程序博客网 时间:2024/05/17 02:48
CString path_exclusive_exe, path_lnclude_exe;//含有.exe的路径和不含的GetModuleFileName(NULL, path_lnclude_exe.GetBuffer(MAX_PATH), MAX_PATH);path_lnclude_exe.ReleaseBuffer();for (int i = 0; i <path_lnclude_exe.GetLength(); i++){if (path_lnclude_exe[i]=='\\'){path_lnclude_exe .Insert(i,'\\');//填充,使得‘\’变为‘\\’i = i + 2;path_exclusive_exe = path_lnclude_exe.Left(i);//不含xxxx.exe}}//以上为获得执行文件的绝对路径,含xxxx.exe 

原创粉丝点击