Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Основная";
Текущий архив: 2002.12.26;
Скачать: [xml.tar.bz2];

Вниз

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

 
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;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.45 MB
Время: 0.012 c
3-85875
daimon
2002-12-08 18:11
2002.12.26
Тонкии клиент


3-85870
Silenser
2002-12-04 07:40
2002.12.26
Виснет SQL


14-86134
Natali
2002-12-06 09:13
2002.12.26
спец. прога для документирования


8-86044
Sam Stone
2002-09-10 08:31
2002.12.26
Иконки


3-85823
maxx2000
2002-12-06 13:23
2002.12.26
Foreign Key for Paradox





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский