Solved

Export a registry key to reg file

Posted on 2006-07-12
5
415 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

734 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