CString strPath;
CString oldpath;
::GetModuleFileName(NULL,strPath.GetBufferSetLength(MAX_PATH+1),
MAX_PATH);
strPath.ReleaseBuffer();
oldpath=strPath;
int nPos=strPath.ReverseFind('\\');
strPath=strPath.Left(nPos);
CString strFileName;//.Format("%s",strPath);
strFileName.Format("%s",oldpath);
strFileName = strFileName.Right(strFileName.GetLength() - nPos -1);
AfxGetMainWnd()->SetDlgItemText(IDC_EDIT3,strPath);
AfxGetMainWnd()->SetDlgItemText(IDC_EDIT4,strFileName);
CString oldpath;
::GetModuleFileName(NULL,strPath.GetBufferSetLength(MAX_PATH+1),
MAX_PATH);
strPath.ReleaseBuffer();
oldpath=strPath;
int nPos=strPath.ReverseFind('\\');
strPath=strPath.Left(nPos);
CString strFileName;//.Format("%s",strPath);
strFileName.Format("%s",oldpath);
strFileName = strFileName.Right(strFileName.GetLength() - nPos -1);
AfxGetMainWnd()->SetDlgItemText(IDC_EDIT3,strPath);
AfxGetMainWnd()->SetDlgItemText(IDC_EDIT4,strFileName);
本文介绍了一种使用C++中的CString类来获取并处理当前模块文件路径的方法。具体步骤包括获取完整路径、提取目录部分及文件名,并展示如何利用MFC对话框控件显示这些信息。
1357

被折叠的 条评论
为什么被折叠?



