Главная страница
    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.45 MB
Время: 0.007 c
1-85996
abat
2002-12-16 12:02
2002.12.26
Проверка существования объекта


1-85999
Alpine
2002-12-16 12:50
2002.12.26
Как запретить своему приложению не запускаться больше одного раза


3-85801
BorisUK
2002-12-06 07:55
2002.12.26
Вынесение запроса к базе в поток


14-86131
malkolinge
2002-12-05 12:21
2002.12.26
Кто за сколько грохнет человеческое существо ?


3-85808
sasha123
2002-12-06 10:23
2002.12.26
Как связать горизонтальную прокрутку в DBGrid c HeaderControl





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
Английский Французский Немецкий Итальянский Португальский Русский Испанский