Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Export a registry key to reg file

Posted on 2006-07-12
5
Medium Priority
?
421 Views
Last Modified: 2010-10-05
Hi.

I need to export a key (containing subkeys) before i delete it.
Is there any Windows API for that ?

Thanks in advance.
0
Comment
Question by:CodedK
  • 3
  • 2
5 Comments
 
LVL 26

Accepted Solution

by:
Russell Libby earned 1200 total points
ID: 17092483
You can use RegSaveKey if you don't care that format is binary. Now if you want to export to a text format (Same as regedit does) that can be imported back in using regedit, then check out my RegTransfer unit @:

http://users.adelphia.net/~rllibby/downloads/regtransfer.zip

I will also post a demo of it in a second.

Regards,
Russell
0
 
LVL 26

Expert Comment

by:Russell Libby
ID: 17092517

Example code:

procedure TForm1.Button1Click(Sender: TObject);
var  strmFile:      TFileStream;
     dwMark:        LongWord;
begin

  dwMark:=GetTickCount;

  // Create stream
  strmFile:=TFileStream.Create('c:\testing.reg', fmCreate);
  try
     // Start the export
     RegExportBegin(strmFile);
     // Export a key and all its sub keys / values
     RegExportKey(strmFile, HKEY_CURRENT_USER, 'Software\Microsoft');
     // End the export
     RegExportEnd(strmFile);
  finally
     // Free the stream
     strmFile.Free;
  end;

  dwMark:=GetTickCount-dwMark;
  MessageBox(0, PChar(IntToStr(dwMark)), nil, MB_OK);

end;

It does run extermely fast, appx 4MB of data exported / second. The unit is also able to import the data (regedit can import the format as well) at the same speed that regedit can.

Regards,
Russell



0
 
LVL 16

Author Comment

by:CodedK
ID: 17094783
Thanks Russell i'll check it tomorrow.
0
 
LVL 26

Expert Comment

by:Russell Libby
ID: 17095139
No hurry..
Russell
0
 
LVL 16

Author Comment

by:CodedK
ID: 17097561
Thank you very much Russell :) :) :)
It is perfect !
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Screencast - Getting to Know the Pipeline
Suggested Courses

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question