得到程序.exe所在路径

    CString path;
GetModuleFileName(NULL,path.GetBufferSetLength(MAX_PATH+1),MAX_PATH);// 寻找当前安装路径
path.ReleaseBuffer();

//去掉xxx.exe,得到目录
int pos = path.ReverseFind('\\'); // 反向查找第一个backslash
path = path.Left(pos); // 得到该backslash以左的内容

pos = path.ReverseFind('\\');
path = path.Left(pos);


if(!PathFileExists(path)) // 检查路径/文件的合法性

{
return ;
}


编辑器加载中...

posted on 2011-12-20 17:27  LateStop  阅读(403)  评论(0)    收藏  举报

导航