/************************************************************************/
/* 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);
}
}
【框架-MFC】MFC操作注册表
最新推荐文章于 2023-05-14 18:35:04 发布