您的位置:首页 > 其它

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

2013-05-11 00:23 197 查看
/************************************************************************/
/* 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);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: