MFC 获取当前程序运行目录
2016-02-25 16:02
204 查看
//--------------方式1 CString SetSoftDlg::GetCurrentPath() { char lpExePathName[255]; char lpExePath[255]; char lpExeName[255]; char ExeDrive[10]; char exeExt[10]; GetModuleFileName(NULL,lpExePathName,255); _splitpath(lpExePathName,ExeDrive,lpExePath,lpExeName,exeExt); charlpIniPathName[255]; char lpTmpFolderName[255]; char lpCurrentExePath[MAX_PATH]; strcpy(lpIniPathName,ExeDrive); strcat(lpIniPathName,lpExePath); strcpy(lpTmpFolderName,lpIniPathName); strcpy(lpCurrentExePath,lpIniPathName); CString strCurrentPath; strCurrentPath.Format("%s",lpCurrentExePath); return strCurrentPath; } //--------------方式2 CString strPathName; GetModuleFileName(NULL,strPathName.GetBuffer(256),256); strPathName.ReleaseBuffer(256); int nPos = strPathName.ReverseFind('\'); strPathName = strPathName.Left(nPos + 1); MessageBox(strPathName);
相关文章推荐
- 【转】Android最佳性能实践(三)——高性能编码优化
- hibernate_Restrictions用法
- Android事件分发机制完全解析,带你从源码的角度彻底理解(上)
- 【SQL Server】统计表记录数
- jquery.cookie.js 的使用指南
- Android输入法的显示或隐藏
- Android-社会化分享
- 可以访问tomcat主页,不能访问项目(tomcat的写入权限不够)
- Android Drawable 那些不为人知的高效用法
- LINK1123:failure during conversion to COFF:file invalid or corrupt
- jQuery中ajax的4种常用请求方式
- No_16_0225 Java基础学习第六天
- NSOperation基本使用
- Git使用教程(一)--搭建Github环境
- 摄影测量--共线方程
- 【转】Android最佳性能实践(二)——分析内存的使用情况
- 深入理解卡尔曼滤波
- maven 指定默认的本地仓库
- 仿微信朋友圈,仿微信小视频 ,录制视频功能
- Android开发:shape和selector和layer-list的(详细说明)