Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2002.12.26;
Скачать: CL | DM;

Вниз

Как сохранить ветку реестра?   Найти похожие ветки 

 
Seldon   (2002-12-15 23:46) [0]

Пишу так:
Reg:=TRegistry.Create;
Reg.RootKey:=HKEY_CURRENT_USER;
Reg.SaveKey("\Software","C:\Soft.reg")
Создаётся пустой файл.


 
Anatoly Podgoretsky ©   (2002-12-15 23:57) [1]

Читаем внимательно хелп
On FAT file systems FileName cannot include an extension.

Ну в дополнение еще куча проблем
1. это не reg файл
2. нельзя использовать HKEY_CURRENT_USER


 
Kotka ©   (2002-12-16 00:08) [2]

Это было в архиве форумов. Здесь могут быть ошибки.

Экспортирует ветк, заданную в Path в файл формата
Regedit.procedure ExportBranchToFile(RootKey: HKEY;Path: string;Filename:string);
var Reg: TRegistry;
ExpFile: TextFile;
P: PCHAR; // Buffer for "bynary" data from registry ;
procedure ProcessBranch(root: string); {recursive sub-procedure} ;
var
Values, Keys: TStringList;
I, J, K: Integer;
S, T: string; {longstrings are on the heap, not on the stack!}
begin
Writeln(ExpFile);{write blank line}
Writeln(ExpFile, "[" + HKEYToString(RootKey) + "\" + root + "]");
Reg.OpenKey(Root, False);
Values := TStringList.Create;
Keys := TStringList.Create;
Reg.GetValueNames(Values); {get all value names}
Reg.GetKeyNames(Keys); {get all sub-branches}
for I := 0 to Values.Count - 1 do {write all the values first}
begin
S := values[I];
T := S; {s=value name};
if S = "" then
S := "@" {empty means "default value", write as @}
else
S := """ + S + """; {else put in quotes}
Write(ExpFile, DupBackSlash(S) + "=");{write the name of the key to the file}
case Reg.GetDataType(T) of {What type of data is it?}
rdString, rdExpandString: {String-type}
Writeln(ExpFile, """ + DupBackSlash(Reg.ReadString(T) + """));
rdInteger: {32-bit unsigned long integer}
Writeln(ExpFile, "dword:" + IntToHex(Reg.ReadInteger(T), 8));{write an array of hex bytes if data is "binary." Perform a line feed after approx. 25 numbers so the line length stays within limits}
rdBinary: begin Write(ExpFile, "hex:");
J := Reg.GetDataSize(T); {determine size}
GetMem(P, J); {Allocate memory}
Reg.ReadBinaryData(T, P^, J); {read in the data, treat as pchar};
for K := 0 to J - 1 do
begin
Write(ExpFile, IntToHex(Byte(p[k]), 2)); {Write byte as hex}
if K <> J - 1 then {not yet last byte?}
begin
Write(ExpFile, ","); {then write Comma}
if (K > 0) and ((K mod 25) = 0) {line too long?} then
Writeln(ExpFile, "\"); {then write Backslash + lf}
end; {if}
end; {for}
FreeMem(P, J); {free the memory}
Writeln(ExpFile); {Linefeed}
end
else
Writeln(ExpFile, """");{write an empty string if datatype illegal/unknown}
end; {case}
end; {for}
Reg.CloseKey;{value names all done, no longer needed}
Values.Free;{Now al values are written, we process all subkeys} {Perform this process RECURSIVELY...}
for I := 0 to Keys.Count - 1 do
ProcessBranch(Root + "\" + Keys[I]);
Keys.Free; {this branch is ready}
end;
begin ;
if Path[Length(Path)] = "\" then {No trailing backslash}
SetLength(Path, Length(Path) - 1);
AssignFile(ExpFile, FileName); {create a text file}
ReWrite(ExpFile);
if IOResult <>0 then EXIT;
Writeln(ExpFile, "REGEDIT4"); {"magic key" for regedit}
Reg := TRegistry.Create;
try Reg.RootKey := RootKey;
ProcessBranch(Path);{Call the function that writes the branch and all subbranches}
finally;
Reg.Free; {ready}
Close(ExpFile);
end;
end;



Страницы: 1 вся ветка

Текущий архив: 2002.12.26;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.021 c
14-86130
C.I.A.
2002-12-04 21:06
2002.12.26
DelphiX


1-85979
Socol
2002-12-15 02:10
2002.12.26
Нужна помошь с отслеживанием клавишь)))


3-85818
Мученик
2002-12-06 12:08
2002.12.26
Хранимая процедура


3-85862
and_sp
2002-12-03 09:32
2002.12.26
Paradox в Excel


14-86161
Uran
2002-12-06 16:53
2002.12.26
Откуда можно скачать программу DMFC, для чтения этого форума?