Question: | How do I use the TRegistry::SaveKey and TRegistry::LoadKey functions to backup registry keys? |
Solution: | This is an example of how to use
TRegisty::LoadKey and TRegistry::SaveKey for making
backups of your registry. These functions store the data
in what is called a hive file. Once saved the Key can be
loaded (along with all its sub_keys back into the
registry. This function has very limited uses because of
the following: a) A key that has been saved and then reloaded with load can not be deleted, it can only be programatically removed using UnLoadKey. b) Save file can only save to files that don't have an extenstion, and the file can not exist. c) LoadKey can only work when it is loading to a key that does not already exist. |
Code: | /*Function SaveKey: [in] String
sFileName = file to save to
*/ void SaveKey (String sFileName, String sKeyName){ //You can only use HKEY_LOCAL_MACHINE and HKEY_USERS as //root when using the TRegistry::SaveKey & TRegistry::LoadKey methods //reg->RootKey = HKEY_LOCAL_MACHINE; //you cannot save a Key to a file that exists. So, here I am //checking to see if the file "reg" exists //note: you cannot save to a file with an extention!!
} /* Function LoadKey: [in] sFileName = File to load from
void LoadKey (String sFileName, String sKeyName){
} |
Last Modified: 05-OCT-99