1.方法1

          ?? char pBuf[MAX_PATH];?????????????????????????????????????????????? //存放路徑的變量
          ?? GetCurrentDirectory(MAX_PATH,pBuf);?????????????????? //獲取程序的當前目錄
          ?? strcat(pBuf,"\\");
          ?? strcat(pBuf,AfxGetApp()->m_pszExeName);???
          ?? strcat(pBuf,".exe");?????????????????????????????????????????????????????? //獲取程序的全文件名

          2.方法2

          ?? //函數返回應用程序所在的路徑??

          ?? CString??? CClientApp::ReturnPath()??

          ?? {???
          ?? CString??? sPath;???
          ?? GetModuleFileName(NULL,sPath.GetBufferSetLength(MAX_PATH+1),MAX_PATH);???
          ?? sPath.ReleaseBuffer??? ();???
          ?? int??? nPos;???
          ?? nPos=sPath.ReverseFind('\\');???
          ?? sPath=sPath.Left(nPos);???
          ?? return??? sPath;???
          ?? }

          ?、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、

          CFileDialog dlg(TRUE)?

          CFileDialog dlg(TRUE);//<-這里用TRUE與FALSE有什么不同?

          ???? // TRUE是“打開”對話框
          ???? // FALSE是“另存為”對話框
          int ret=dlg.DoModal();
          if(ret==IDOK)
          {
          CString pathname=dlg.GetPathName();? //得到文件所在路徑+文件名
          CString filename=dlg.GetFileName(); //得到文件名
          char tbuf[120];
          sprintf(tbuf,"The %s file in %s is saved!",filename,pathname);
          AfxMessageBox(tbuf);

          }

          posted on 2009-06-16 16:06 -274°C 閱讀(25306) 評論(0)  編輯  收藏 所屬分類: C++

          常用鏈接

          留言簿(21)

          隨筆分類(265)

          隨筆檔案(242)

          相冊

          JAVA網站

          關注的Blog

          搜索

          •  

          積分與排名

          • 積分 - 914107
          • 排名 - 40

          最新評論

          主站蜘蛛池模板: 安西县| 江都市| 藁城市| 涟源市| 枣阳市| 巴彦淖尔市| 安顺市| 永安市| 改则县| 伊春市| 临澧县| 阿尔山市| 巴东县| 昌图县| 望江县| 宜章县| 延边| 长子县| 竹溪县| 雷山县| 彩票| 咸阳市| 开远市| 永川市| 凤翔县| 商城县| 鸡西市| 高雄市| 陆河县| 方山县| 察隅县| 临泉县| 泽普县| 福建省| 河北区| 应城市| 民乐县| 芜湖县| 双牌县| 阿瓦提县| 涿州市|