• <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++博客 :: 首頁 :: 聯系 :: 聚合  :: 管理
              140 Posts :: 1 Stories :: 11 Comments :: 0 Trackbacks

            常用鏈接

            留言簿(1)

            我參與的團隊

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

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

            實現:
             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 閱讀(590) 評論(0)  編輯 收藏 引用 所屬分類: VC / C++
            久久这里有精品视频| 久久亚洲精精品中文字幕| 国产成人久久精品麻豆一区 | 亚洲精品97久久中文字幕无码| 伊人久久无码精品中文字幕| 久久SE精品一区二区| 97久久精品无码一区二区| 久久av免费天堂小草播放| 丁香色欲久久久久久综合网| 99久久伊人精品综合观看| 久久综合亚洲色HEZYO社区 | 久久66热人妻偷产精品9| 久久久久无码精品| 99久久精品国内| 奇米影视7777久久精品人人爽| 99久久国语露脸精品国产| 精品久久久一二三区| 亚洲综合精品香蕉久久网97| 亚洲中文字幕无码久久综合网| a级毛片无码兔费真人久久| 色诱久久久久综合网ywww| 久久国产美女免费观看精品| 久久国产乱子精品免费女| 午夜精品久久久久久99热| 久久夜色精品国产亚洲| 久久久久人妻一区精品| 94久久国产乱子伦精品免费| 999久久久免费国产精品播放| 久久亚洲精品国产亚洲老地址| 91精品国产91久久综合| 少妇熟女久久综合网色欲| 久久精品综合一区二区三区| 久久久中文字幕| 91精品国产色综合久久| 亚洲精品乱码久久久久66| 久久精品无码一区二区WWW| 久久伊人色| 久久亚洲国产精品五月天婷| 久久精品一区二区影院| 久久久精品日本一区二区三区 | 99久久人妻无码精品系列蜜桃|