【框架-MFC】MFC操作注册表

来源:互联网 发布:fastjson json转对象 编辑:程序博客网 时间:2024/05/19 23:58
/************************************************************************//* MFC操作注册表                                                   *//************************************************************************/class CWinAppX : public CWinAppEx{public:CWinAppX();};// 唯一的一个 CWinAppX 对象CWinAppX theApp;std::list<CString>   pFilePath;std::list<CString>::iterator ite;/************************************************************************//* 将字符串写入注册表                                                   *//************************************************************************/void  WriteRegedit()//CMainFram析构时{CString strTmp;if(pFilePath.size()>8)pFilePath.resize(8);//重新设置文件路径个数theApp.WriteProfileInt(L"ZhuiJinDaKaiWenJian",L"Counts",pFilePath.size());ite= pFilePath.begin();int i=0;while(ite!= pFilePath.end()){strTmp.Format(L"%d",i+1);theApp.WriteProfileStringW(L"ZhuiJinDaKaiWenJian",strTmp,*ite);ite++;i++;}}/************************************************************************//* 将字符串从注册表读取出来                                             *//************************************************************************/void  ReadRegedit()//CMainFram构造时{CString strTmp;int counts= theApp.GetProfileIntW(L"ZhuiJinDaKaiWenJian",L"Counts",0);for(int i=0;i<counts;i++){strTmp.Format(L"%d",i+1);CString str= theApp.GetProfileStringW(L"ZhuiJinDaKaiWenJian",strTmp,L"");if(str.IsEmpty())continue;m_vLately.push_back(str);}}