Solved

Export a registry key to reg file

Posted on 2006-07-12
5
410 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 300 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to fill array with TArray.Create? 14 90
Magic Software info 18 132
Press three keys together and trigger a function 3 57
can't find the executable in Simulator 1 90
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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

803 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