• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            積木

            No sub title

              C++博客 :: 首頁(yè) :: 聯(lián)系 :: 聚合  :: 管理
              140 Posts :: 1 Stories :: 11 Comments :: 0 Trackbacks

            常用鏈接

            留言簿(1)

            我參與的團(tuán)隊(duì)

            搜索

            •  

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            聲明:
             1 /************************************************************************/
             2 /** 系統(tǒng)全局函數(shù)
             3 /************************************************************************/
             4 
             5 #pragma once
             6 
             7 #include <string>
             8 
             9 // 取得應(yīng)用程序路徑(末尾帶 '\' 的)
            10 CString ExtractFilePath(void);
            11 // 取得應(yīng)用程序路徑(末尾不帶 '\' 的)
            12 CString ExtractFileDir(void);
            13 // 取得指定文件的目錄(參數(shù)為文件的完整路徑,返回值末尾不帶 '\' 的)
            14 CString GetFileDir(const CString& csFullFileName);
            15 // 取得指定文件的目錄(參數(shù)為文件的完整路徑,返回值末尾帶 '\' 的)
            16 CString GetFilePath(const CString& csFullFileName);
            17 // 將CString轉(zhuǎn)換成string(將Unicode串轉(zhuǎn)換成Ansi(返回string))
            18 std::string ConvertW2A(const CString& csString);
            19 // 將路徑中的指定字符用另外的指定字符替換,并返回(string)
            20 std::string StringReplace(const char* pszString, const char cSourceChar, const char cDestChar);

            實(shí)現(xiàn):
             1 #include "stdafx.h"
             2 #include "GlobalFunction.h"
             3 #include <atlconv.h>
             4 
             5 CString ExtractFileDir(void)
             6 {
             7     CString csResult;
             8     WCHAR pszExeFullPath[MAX_PATH];
             9     ::GetModuleFileName(NULL, pszExeFullPath, MAX_PATH);
            10     csResult = pszExeFullPath;
            11     int iPos = csResult.ReverseFind('\\');
            12     csResult = csResult.Left(iPos);
            13     return csResult;
            14 }
            15 
            16 CString ExtractFilePath(void)
            17 {
            18     CString csResult = ExtractFileDir();
            19     if (csResult.GetLength() > 0)
            20         return csResult + L"\\";
            21     return csResult;
            22 }
            23 
            24 CString GetFileDir(const CString& csFullFileName)
            25 {
            26     if (!::PathFileExists(csFullFileName))
            27         return CString(L"");
            28 
            29     CString csResult(csFullFileName);
            30     int iPos = csResult.ReverseFind('\\');
            31     csResult = csResult.Left(iPos);
            32     return csResult;
            33 }
            34 
            35 CString GetFilePath(const CString& csFullFileName)
            36 {
            37     CString csResult = GetFileDir(csFullFileName);
            38     if (csResult.GetLength() > 0)
            39         csResult + "\\";
            40     return csResult;
            41 }
            42 
            43 std::string ConvertW2A(const CString& csString)
            44 {
            45     USES_CONVERSION;
            46     return std::string(W2A(csString));
            47 }
            48 
            49 std::string StringReplace(const char* pszString, const char cSourceChar, const char cDestChar)
            50 {
            51     if (strlen(pszString) == 0)
            52         return std::string("");
            53     const UINT iLen = strlen(pszString) + 1;
            54     char* pszTargetString = new char[iLen];
            55     //char pszTargetString[iLen];
            56     try
            57     {
            58         strncpy(pszTargetString, pszString, iLen);
            59         for (int iIndex = 0; iIndex != iLen; iIndex++)
            60         {
            61             if (pszTargetString[iIndex] == cSourceChar)
            62                 pszTargetString[iIndex] = cDestChar;
            63         }
            64         delete [] pszTargetString;
            65         return std::string(pszTargetString);
            66     }
            67     catch ()
            68     {
            69         delete [] pszTargetString;
            70         return std::string("");
            71     }
            72 }
            posted on 2011-06-15 15:35 Jacc.Kim 閱讀(599) 評(píng)論(0)  編輯 收藏 引用 所屬分類: VC / C++
            久久99国产综合精品女同| 久久精品国产男包| 久久www免费人成看国产片| 青青青青久久精品国产h| 久久精品国产亚洲Aⅴ香蕉| 午夜视频久久久久一区| 欧美午夜精品久久久久免费视| 亚洲AV无码久久精品蜜桃| 久久人爽人人爽人人片AV| 日本道色综合久久影院| 伊人久久大香线蕉AV一区二区| 伊人久久大香线蕉av不变影院 | 99久久成人18免费网站| 亚洲人AV永久一区二区三区久久| 精品久久久一二三区| 久久精品国产亚洲欧美| 久久中文字幕精品| 99久久精品国产一区二区蜜芽| 2021国产精品午夜久久| 99久久精品国产一区二区蜜芽| 欧美国产成人久久精品| 久久久久国产精品| 999久久久免费精品国产| 久久青青草原精品国产软件| 亚洲综合久久夜AV | 久久精品国产69国产精品亚洲| 久久精品国产男包| 久久久这里有精品| 久久一区二区三区免费| 亚洲va久久久噜噜噜久久天堂| 久久久精品波多野结衣| 国产国产成人精品久久| 久久人人爽人人爽人人片AV东京热| 99久久国产免费福利| 91久久精一区二区三区大全| 久久综合狠狠综合久久97色| 久久一日本道色综合久久| 婷婷久久五月天| 亚洲AV日韩精品久久久久久久| 一级女性全黄久久生活片免费 | 国产V亚洲V天堂无码久久久|