visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
316 experts, 1194 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Languages :: Delphi :: How to back up registry in Win98se/winXP with Delphi?


By: collegeBoy U.S.A.  Date: 08/04/2003 00:00:00  English  Points: 125 Status: Answered
Quality : Excellent
Hey everyone,
I have some problems about that backuping. If you can, please answer me.
This should be an Api funkcion or smth.

Best regards to everyone!
By: VGR Date: 08/04/2003 06:29:00 English  Type : Answer
my PersonalBackup software does it.

On Win95/98 you can just copy the config/* files
on NT/XP/2K you've to SaveKey using a TRegistry object, after having got the required SE_BACKUP_NAME privilege

regards
By: TheFalklands Date: 09/04/2003 05:34:00 English  Type : Comment
Use these codes to backup the Registry's any branch:

winexec('regedit /e c:\goomoo.reg HKEY_LOCAL_MACHINE\Software\Microsoft',sw_show);
By: VGR Date: 09/04/2003 05:53:00 English  Type : Comment
it won't work if the user hasn't the required privilege. This requires some programming.

PersonalBackup is at <A HREF="http://www.edainworks.com">www.edainworks.com</a>
By: digitaltree Date: 09/04/2003 07:27:00 English  Type : Comment
Try this:


No 1.use regedit uses shellapi
shellexecute(handle,'open','regedit.exe',' /e YourWantExportKey YourBackUpFilename','',sw_hide)

No 2.Use windows API RegSaveKey or RegRestoreKey

The RegSaveKey function saves the specified key and all of its subkeys
and values to a new file.

LONG RegSaveKey(
HKEY hKey, // handle of key where save begins
LPCTSTR lpFile, // address of filename to save to
LPSECURITY_ATTRIBUTES lpSecurityAttributes // address of security structure
);

The RegRestoreKey function reads the registry information in a specified file and copies it over the specified key. This registry information may be in the form of a key and multiple levels of subkeys.

LONG RegRestoreKey(
HKEY hKey, // handle of key where restore begins
LPCTSTR lpFile, // address of filename containing saved tree
DWORD dwFlags // optional flags
);

example code:
procedure TFormMain.ButtonExportClick(Sender: TObject);
var
RootKey,phKey: hKey;
KeyName,sKeyFileName: String;
FileName: array [0..255] of char;
begin
RootKey := HKEY_CURRENT_USER;
KeyName := 'software\mysoft\abc';
RegOpenKeyEx(RootKey, PChar(KeyName), 0, KEY_ALL_ACCESS, phKey);
sKeyFileName := 'c:\tempReg';
StrPCopy(FileName,sKeyFileName); //or use pchar
if RegSaveKey(phKey, FileName, nil)= 0 then
ShowMessage('BACKUP OK!')
else
ShowMessage('BACKUP ERROR!');
RegCloseKey(phKey);
end;

procedure TFormMain.ButtonImportClick(Sender: TObject);
var //Restore from file
RootKey,phKey: hKey;
KeyName,sKeyFileName: String;
FileName: array [0..255] of char;
begin
RootKey := HKEY_CURRENT_USER;
KeyName := 'software\mySoft\abc';
RegOpenKeyEx(RootKey, PChar(KeyName), 0, KEY_ALL_ACCESS, phKey);
sKeyFileName := 'c:\tempReg';
StrPCopy(FileName,sKeyFileName);
if RegRestoreKey(phKey, FileName,0)= 0 then
ShowMessage('RESTORE OK!')
else
ShowMessage('RESTORE ERROR!');
RegCloseKey(phKey);
end;


No 3.Use TRegistry's savekey and restorekey
var
reg : Tregistry;
begin
reg := Tregistry.Create;
reg.rootkey := HKEY_CURRENT_USER;
reg.Savekey('\Software\Wom','d:\test1\Wom');
end;





By: VGR Date: 09/04/2003 07:34:00 English  Type : Comment
one more time, this SaveKey call won't work if the user the program runs at doesn't have the required NT privilege
By: collegeBoy Date: 22/04/2003 02:02:00 English  Type : Comment
Thanx for all of you

Do register to be able to answer

EContact
browser fav
page generated in 394.836900 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page