Click here to Skip to main content
16,019,768 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Comments
Albert Holguin 12-Apr-11 17:32pm    
did you mean the entire registry or just certain keys?

1 solution

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
 
Share this answer
 
Comments
akj2690 11-Apr-11 14:15pm    
It looks good to me..........
5 for

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900