如何进行注册表备份 [英] how to take registry backup

查看:69
本文介绍了如何进行注册表备份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个备份资源实用程序,在其中我必须备份所有注册表项并还原它.如何使用注册表备份以及如何使用mfc将这些条目还原回注册表.
谢谢

i am making a backup resotre utility where i have to take backup of all my registry entries as well as to restore it . How can i take registry backup as well as how to restore these entries back to registry using mfc.
thank you

推荐答案

通过使用以下CWinApp成员函数:

-``CWinApp :: GetProfileString()''
-``CWinApp :: GetProfileInt()''
-``CWinApp :: WriteProfileString()''
-``CWinApp :: WriteProfileInt()''

在调用任何上述函数之前,必须调用"CWinApp :: SetRegistryKey()".这将导致应用程序设置存储在注册表中,而不是常规INI文件中.

此外,"CWinApp"注册表函数将在"SetRegistryKey()"的"HKEY_CURRENT_USER \ Software \< lpszRegistryKey"自变量下读取/写入. SetRegistryKey(_T("Zerolei软件"));

//从
读取用户名"注册表项(值) //HKEY_CURRENT_USER \ Software \ Zerolei Software \ MyApp \ Login键
m_strUserName = GetProfileString(m_pszLoginSection,m_pszUserNameEntry);

//...
返回TRUE;
}

int CMyApp :: ExitInstance()
{
//在
下的用户名"注册表项(值)中写入"m_strUserName" //HKEY_CURRENT_USER \ Software \ Zerolei Software \ MyApp \ Login键
WriteProfileString(m_pszLoginSection,m_pszUserNameEntry,m_strUserName);

//...
返回CWinApp :: ExitInstance();
}


让我知道这是否有效:-)
-

AJ
By using the following CWinApp member functions:

- ''CWinApp::GetProfileString()''
- ''CWinApp::GetProfileInt()''
- ''CWinApp::WriteProfileString()''
- ''CWinApp::WriteProfileInt()''

Before calling any of above functions, you have to call ''CWinApp::SetRegistryKey()''. This causes application settings to be stored in the registry instead of regualr INI files.

Further, ''CWinApp'' registry functions will read/write under ''HKEY_CURRENT_USER\Software\<''lpszRegistryKey'' argument of ''SetRegistryKey()''>\<lpszsection''> SetRegistryKey(_T("Zerolei Software"));

// Read "User Name" registry entry (value) from
// HKEY_CURRENT_USER\Software\Zerolei Software\MyApp\Login key
m_strUserName = GetProfileString(m_pszLoginSection, m_pszUserNameEntry);

// ...
return TRUE;
}

int CMyApp::ExitInstance()
{
// write ''m_strUserName'' in "User Name" registry entry (value) under
// HKEY_CURRENT_USER\Software\Zerolei Software\MyApp\Login key
WriteProfileString(m_pszLoginSection, m_pszUserNameEntry, m_strUserName);

// ...
return CWinApp::ExitInstance();
}


Let me know if this works :-)
--

AJ


这篇关于如何进行注册表备份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆