Solved

Export a registry key to reg file

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

920 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

13 Experts available now in Live!

Get 1:1 Help Now