c++ 获取当前程序(EXE)所在的路径.docxVIP

  • 22
  • 0
  • 约 3页
  • 2021-11-08 发布于江苏
  • 举报
c++ 获取当前程序(EXE)所在的路径.docx

c/c++ 获取当前程序(EXE) 所在的路径 一、1.只获得路径字串不包含文件名 TCHAR szFilePath[MAX_PATH + 1]={0}; GetModuleFileName(NULL, szFilePath, MAX_PATH); (_tcsrchr(szFilePath, _T(\\)))[删1]除=文0件;/名/ ,只获得路径字串 CString str_url = szFilePat例h;如//str_url==e:\program\Debug\ 2.获得双斜杠路径不包含文件名 TCHAR _szPath[MAX_PATH + 1]={0}; GetModuleFileName(NULL, _szPath, MAX_PATH); (_tcsrchr(_szPath, _T(\\)))[1删] CString strPath; for (int n=0;_szPath[n];n++) { if (_szPath[n]!=_T(\\)) { 除= 文0;件//名,只获得路径 字串 strPath +=_szPath[n] ; } else { strPath += _T(\\\\); } } MessageBox(strPath);/输/ 二、 出==e:\\program\\Debug\\ 1:获取应用程序自身完整路径文件名方法 1: #in

文档评论(0)

1亿VIP精品文档

相关文档