//--------------方式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);