собственно вот рабочий код если кому надо....
procedure ExportRegistryBranch(Rootsection: Integer; regroot: string;
FileName: string);
implementation
function FindDBL (s: string): integer;
var
i, count: integer;
begin
count := 0;
for i:=1 to length(s) do
if s[i]='\"' then
begin
count := count+1;
end;
FindDBL := count;
end;
function dblBackSlash(t: string): string;
var
k: longint;
begin
Result := t;
for k := Length(t) downto 1 do
if Result[k] = '\' then Insert('\', Result, k);
end;
procedure ExportRegistryBranch(rootsection: Integer; Regroot: string;
FileName: string);
var
reg: TRegistry;
f: Textfile;
p: PChar;
correct:string;
procedure ProcessBranch(root: string);
var
values, keys: TStringList;
i, j, k: longint;
s, t: string;
begin
Writeln(f);
case rootsection of
HKEY_CLASSES_ROOT: s := 'HKEY_CLASSES_ROOT';
HKEY_CURRENT_USER: s := 'HKEY_CURRENT_USER';
HKEY_LOCAL_MACHINE: s := 'HKEY_LOCAL_MACHINE';
HKEY_USERS: s := 'HKEY_USERS';
HKEY_PERFORMANCE_DATA: s := 'HKEY_PERFORMANCE_DATA';
HKEY_CURRENT_CONFIG: s := 'HKEY_CURRENT_CONFIG';
HKEY_DYN_DATA: s := 'HKEY_DYN_DATA';
end;
Writeln(f, '[' + s + root + ']');
reg.OpenKey(root, False);
try
values := TStringList.Create;
try
keys := TStringList.Create;
try
reg.GetValuenames(values);
reg.GetKeynames(keys);
for i := 0 to values.Count - 1 do
begin
s := values[i];
t := s;
if s = ''
then s := '@'
else s := '\"' + s + '\"';
Write(f, dblbackslash(s) + '=');
case reg.Getdatatype(t) of
rdString, rdExpandString:
if FindDBL(dblbackslash(reg.ReadString(t)))>0 then
begin
correct := StringReplace(dblbackslash(reg.ReadString(t)), '\"', '\\"',[rfReplaceAll, rfIgnoreCase]);
Writeln(f, '\"' + correct + '\"');
end
else Writeln(f, '\"' + dblbackslash(reg.ReadString(t) + '\"'));
rdInteger:
Writeln(f, 'dword:' + IntToHex(reg.readinteger(t), 8));
rdBinary:
begin
Write(f, 'hex:');
j := reg.GetDataSize(t);
GetMem(p, j);
reg.ReadBinaryData(t, p^, J);
for k := 0 to j - 1 do
begin
Write(f, IntToHex(Byte(p[k]), 2));
if k <> j - 1 then
begin
Write(f, ',');
if (k > 0) and ((k mod 25) = 0) then
Writeln(f, '\');
end;
end;
FreeMem(p, j);
Writeln(f);
end;
else
Writeln(f, '\"\"');
end;
end;
finally
reg.CloseKey;
end;
finally
values.Free;
end;
for i := 0 to keys.Count - 1 do
ProcessBranch(root + '\' + keys[i]);
finally
keys.Free;
end;
end;
begin
if RegRoot[Length(Regroot)] = '\' then
SetLength(regroot, Length(Regroot) - 1);
Assignfile(f, FileName);
Rewrite(f);
if ioResult <> 0 then Exit;
Writeln(f, 'Windows Registry Editor Version 5.00');
reg := TRegistry.Create;
try
reg.Rootkey := Rootsection;
ProcessBranch(Regroot);
finally
reg.Free;
Close(f);
end;
end;
_____________________________________
ExportRegistryBranch(HKEY_CURRENT_USER,'\Software\key\','c:\1.reg');