• <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>

            牽著老婆滿街逛

            嚴以律己,寬以待人. 三思而后行.
            GMail/GTalk: yanglinbo#google.com;
            MSN/Email: tx7do#yahoo.com.cn;
            QQ: 3 0 3 3 9 6 9 2 0 .

            VC CIni

            //文件??1:??

            #pragma??once??






            #include??
            " afxTempl.h " ??






            class ??CIni??



            {??



            private :??



            ?????CString??m_strFileName;??



            public :??



            ?????CIni(CString??strFileName):m_strFileName(strFileName)??



            ?????
            {??



            ?????}
            ??



            public :??



            ?????
            // 一般性操作:??



            ?????BOOL??SetFileName(LPCTSTR??lpFileName);????
            // 設置文件名??



            ?????CString??GetFileName(
            void );?? // 獲得文件名??



            ?????BOOL??SetValue(LPCTSTR??lpSection,??LPCTSTR??lpKey,??LPCTSTR??lpValue,
            bool ??bCreate = true );?? // 設置鍵值,bCreate是指段名及鍵名未存在時,是否創建。??



            ?????CString??GetValue(LPCTSTR??lpSection,??LPCTSTR??lpKey);??
            // 得到鍵值.??



            ?????BOOL??DelSection(LPCTSTR??strSection);????
            // 刪除段名??



            ?????BOOL??DelKey(LPCTSTR??lpSection,??LPCTSTR??lpKey);????
            // 刪除鍵名??









            public :??



            ?????
            // 高級操作:??



            ?????
            int ??GetSections(CStringArray & ??arrSection);???? // 枚舉出全部的段名??



            ?????
            int ??GetKeyValues(CStringArray & ??arrKey,CStringArray & ??arrValue,LPCTSTR??lpSection);???? // 枚舉出一段內的全部鍵名及值??






            ?????BOOL??DelAllSections();??






            }
            ;??


            //文件??2:??
            #include??"StdAfx.h"??



            #include??
            "ini.h"??






            #define??MAX_ALLSECTIONS??2048????//全部的段名??



            #define??MAX_SECTION??260????//一個段名長度??



            #define??MAX_ALLKEYS??6000????//全部的鍵名??



            #define??MAX_KEY??260????//一個鍵名長度??






            BOOL??CIni::SetFileName(LPCTSTR??lpFileName)??



            {??



            ?????CFile??file;??



            ?????CFileStatus??status;??






            ?????
            if(!file.GetStatus(lpFileName,status))??



            ?????????
            return??TRUE;??






            ?????m_strFileName
            =lpFileName;??



            ?????
            return??FALSE;??



            }
            ??






            CString??CIni::GetFileName(
            void)??



            {??



            ?????
            return??m_strFileName;??



            }
            ??






            BOOL??CIni::SetValue(LPCTSTR??lpSection,??LPCTSTR??lpKey,??LPCTSTR??lpValue,
            bool??bCreate)??



            {??



            ?????TCHAR??lpTemp[MAX_PATH]??
            ={0};??






            ?????
            //以下if語句表示如果設置bCreate為false時,當沒有這個鍵名時則返回TRUE(表示出錯)??



            ?????
            //!*&*none-value*&!*??這是個垃圾字符沒有特別意義,這樣亂寫是防止湊巧相同。??



            ?????
            if??(!bCreate)??



            ?????
            {??



            ?????????GetPrivateProfileString(lpSection,lpKey,
            "!*&*none-value*&!*",lpTemp,MAX_PATH,m_strFileName);??



            ?????????
            if(strcmp(lpTemp,"!*&*none-value*&!*")==0)??



            ??????????????
            return??TRUE;??



            ?????}
            ??






            ?????
            if(WritePrivateProfileString(lpSection,lpKey,lpValue,m_strFileName))??



            ?????????
            return??FALSE;??



            ?????
            else??



            ?????????
            return??GetLastError();??



            }
            ??






            CString??CIni::GetValue(LPCTSTR??lpSection,??LPCTSTR??lpKey)??



            {??



            ?????DWORD??dValue;??



            ?????TCHAR??lpValue[MAX_PATH]??
            ={0};??






            ?????dValue
            =GetPrivateProfileString(lpSection,lpKey,"",lpValue,MAX_PATH,m_strFileName);??



            ?????
            return??lpValue;??



            }
            ??






            BOOL??CIni::DelSection(LPCTSTR??lpSection)??



            {??



            ?????
            if(WritePrivateProfileString(lpSection,NULL,NULL,m_strFileName))??



            ?????????
            return??FALSE;??



            ?????
            else??



            ?????????
            return??GetLastError();??



            }
            ??






            BOOL??CIni::DelKey(LPCTSTR??lpSection,??LPCTSTR??lpKey)??



            {??



            ?????
            if(WritePrivateProfileString(lpSection,lpKey,NULL,m_strFileName))??



            ?????????
            return??FALSE;??



            ?????
            else??



            ?????????
            return??GetLastError();??



            }
            ??









            int??CIni::GetSections(CStringArray&??arrSection)??



            {??



            ?????
            /*??



            ?????本函數基礎:??



            ?????GetPrivateProfileSectionNames??-??從??ini??文件中獲得??Section??的名稱??



            ?????如果??ini??中有兩個??Section:??[sec1]??和??[sec2],則返回的是??'sec1',0,'sec2',0,0??,當你不知道??????



            ?????ini??中有哪些??section??的時候可以用這個??api??來獲取名稱????



            ?????
            */
            ??



            ?????
            int??i;??????



            ?????
            int??iPos=0;??????



            ?????
            int??iMaxCount;??



            ?????TCHAR??chSectionNames[MAX_ALLSECTIONS]
            ={0};??//總的提出來的字符串??



            ?????TCHAR??chSection[MAX_SECTION]
            ={0};??//存放一個段名。??



            ?????GetPrivateProfileSectionNames(chSectionNames,MAX_ALLSECTIONS,m_strFileName);??






            ?????
            //以下循環,截斷到兩個連續的0??



            ?????
            for(i=0;i<MAX_ALLSECTIONS;i++)??



            ?????
            {??



            ?????????
            if??(chSectionNames[i]==0)??



            ??????????????
            if??(chSectionNames[i]==chSectionNames[i+1])??



            ???????????????????
            break;??



            ?????}
            ??






            ?????iMaxCount
            =i+1;??//要多一個0號元素。即找出全部字符串的結束部分。??



            ?????arrSection.RemoveAll();
            //清空原數組??






            ?????
            for(i=0;i<iMaxCount;i++)??



            ?????
            {??



            ?????????chSection[iPos
            ++]=chSectionNames[i];??



            ?????????
            if(chSectionNames[i]==0)??



            ?????????
            {????????



            ??????????????arrSection.Add(chSection);??



            ??????????????memset(chSection,
            0,MAX_SECTION);??



            ??????????????iPos
            =0;??



            ?????????}
            ??






            ?????}
            ??






            ?????
            return??(int)arrSection.GetSize();??



            }
            ??






            int??CIni::GetKeyValues(CStringArray&??arrKey,CStringArray&??arrValue,??LPCTSTR??lpSection)??



            {??



            ?????
            /*??



            ?????本函數基礎:??



            ?????GetPrivateProfileSection-??從??ini??文件中獲得一個Section的全部鍵名及值名??



            ?????如果ini中有一個段,其下有??"段1=值1"??"段2=值2",則返回的是??'段1=值1',0,'段2=值2',0,0??,當你不知道??????



            ?????獲得一個段中的所有鍵及值可以用這個。????



            ?????
            */
            ??



            ?????
            int??i;??????



            ?????
            int??iPos=0;??



            ?????CString??strKeyValue;??



            ?????
            int??iMaxCount;??



            ?????TCHAR??chKeyNames[MAX_ALLKEYS]
            ={0};??//總的提出來的字符串??



            ?????TCHAR??chKey[MAX_KEY]
            ={0};??//提出來的一個鍵名??






            ?????GetPrivateProfileSection(lpSection,chKeyNames,MAX_ALLKEYS,m_strFileName);??






            ?????
            for(i=0;i<MAX_ALLKEYS;i++)??



            ?????
            {??



            ?????????
            if??(chKeyNames[i]==0)??



            ??????????????
            if??(chKeyNames[i]==chKeyNames[i+1])??



            ???????????????????
            break;??



            ?????}
            ??






            ?????iMaxCount
            =i+1;??//要多一個0號元素。即找出全部字符串的結束部分。??



            ?????arrKey.RemoveAll();
            //清空原數組??



            ?????arrValue.RemoveAll();??






            ?????
            for(i=0;i<iMaxCount;i++)??



            ?????
            {??



            ?????????chKey[iPos
            ++]=chKeyNames[i];??



            ?????????
            if(chKeyNames[i]==0)??



            ?????????
            {??



            ??????????????strKeyValue
            =chKey;??



            ??????????????arrKey.Add(strKeyValue.Left(strKeyValue.Find(
            "=")));??



            ??????????????arrValue.Add(strKeyValue.Mid(strKeyValue.Find(
            "=")+1));??



            ??????????????memset(chKey,
            0,MAX_KEY);??



            ??????????????iPos
            =0;??



            ?????????}
            ??






            ?????}
            ??






            ?????
            return??(int)arrKey.GetSize();??



            }
            ??






            BOOL??CIni::DelAllSections()??



            {??



            ?????
            int??nSection;??



            ?????CStringArray??arrSection;??



            ?????nSection
            =GetSections(arrSection);??



            ?????
            for(int??i=0;i<nSection;i++)??



            ?????
            {??



            ?????????
            if(DelSection(arrSection[i]))??



            ??????????????
            return??GetLastError();??



            ?????}
            ??



            ?????
            return??FALSE;??



            }
            ??









            使用方法:??



            CIni??ini(
            "c:\\a.ini");??



            int??n;??






            /*獲得值??



            TRACE("%s",ini.GetValue("段1","鍵1"));??



            */
            ??






            /*添加值??



            ini.SetValue("自定義段","鍵1","值");??



            ini.SetValue("自定義段2","鍵1","值",false);??



            */
            ??






            /*枚舉全部段名??



            CStringArray??arrSection;??



            n=ini.GetSections(arrSection);??



            for(int??i=0;i<n;i++)??



            TRACE("%s\n",arrSection[i]);??



            */
            ??






            /*枚舉全部鍵名及值??



            CStringArray??arrKey,arrValue;??



            n=ini.GetKeyValues(arrKey,arrValue,"段1");??



            for(int??i=0;i<n;i++)??



            TRACE("鍵:%s\n值:%s\n",arrKey[i],arrValue[i]);??



            */
            ??






            /*刪除鍵值??



            ini.DelKey("段1","鍵1");??



            */
            ??






            /*刪除段??



            ini.DelSection("段1");??



            */
            ??






            /*刪除全部??



            ini.DelAllSections();??



            */
            ??

            posted on 2006-04-17 11:24 楊粼波 閱讀(499) 評論(0)  編輯 收藏 引用 所屬分類: 文章收藏

            久久久精品2019免费观看| 久久久久亚洲精品男人的天堂| 久久中文字幕视频、最近更新 | 精品伊人久久大线蕉色首页| 亚洲色大成网站WWW久久九九| 国产美女久久精品香蕉69| 久久av高潮av无码av喷吹| 要久久爱在线免费观看| 久久久久久人妻无码| 亚洲综合日韩久久成人AV| 狠狠精品久久久无码中文字幕| 2021国内精品久久久久久影院| 国产精品久久久久久福利漫画| 一本色道久久综合| 99久久国产亚洲高清观看2024| 久久久亚洲欧洲日产国码是AV| 久久久这里只有精品加勒比| 久久久久久精品成人免费图片| 少妇无套内谢久久久久| 久久精品国产99国产精品亚洲| 少妇久久久久久被弄高潮| 久久久久99精品成人片| 69国产成人综合久久精品| 97超级碰碰碰久久久久| 久久综合丁香激情久久| 久久精品成人欧美大片| 久久发布国产伦子伦精品 | 91亚洲国产成人久久精品网址| 色综合久久中文综合网| 香港aa三级久久三级老师2021国产三级精品三级在 | 久久婷婷色综合一区二区| 伊人久久综合无码成人网| 久久久久亚洲AV无码麻豆| 久久99精品久久久久久| 久久A级毛片免费观看| 青青青青久久精品国产 | 99久久无色码中文字幕人妻| 久久久噜噜噜久久中文福利| 四虎国产精品免费久久久| 国产精品亚洲综合久久| 2021少妇久久久久久久久久|