Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save/Restore registry hive

Status
Not open for further replies.

innuendo

Programmer
Feb 24, 2001
5
0
0
UA
How I can do these tasks with Delphi 5:
1. Save a registry key in a file.
2. Delete a key.
3. Restore a key from file in 1).

Please, provide source code.
Thanks.
smiletiniest.gif
 
Include the unit Registry in your "uses" clause...
Here are some methods of the TRegistry class:

procedure/function.........
var r:TRegistry;
key, fileName:string;
begin
key:='NetBus';
fileName:='testreg';

r:=tregistry.Create;
//-----saving a hive---------------------
r.SaveKey(key, fileName);
//-----deleting a key-------------------
r.DeleteKey(key);
//-----loading a key---------------------
{Note: Before an application calls LoadKey the RootKey property must be set to HKEY_USERS, HKEY_LOCAL_MACHINE ... }
r.RootKey:=HKEY_USERS;
r.LoadKey(key, fileName);
//every one of these methods (except Create) are functions that return true if the operation was successsful, false otherwise
r.CloseKey;
r.Destroy;
end;

The file you save the key on is Read-Only. Change this attribute is the loading doesn't work.
Good luck !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top