Solved

Export a registry key to reg file

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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 Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now