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

Вниз

Работа с реестром   Найти похожие ветки 

 
likeanangel   (2003-05-19 19:10) [0]

Уважаемые Мастера!

Сбросьте пожалуйста какой-нибудь образец реально работающего кода с вызовами RegSaveKey/RegLoadKey - у меня почему-то не получается ;((

Максим


 
VMcL ©   (2003-05-19 19:24) [1]

См. модуль Registry, класс TRegistry


 
Coban ©   (2003-05-20 00:36) [2]

const
Key = "SOFTWARE\TestCompany\TestProgram"; //базовый путь в реестре

function OpenKey(SubKey: String; var Handle: HKEY): Boolean;
begin
Result := RegCreateKey(HKEY_CURRENT_USER, PChar(Key + SubKey), Handle) = ERROR_SUCCESS;
end;

function CloseKey(var Handle: HKey): Boolean;
begin
Result := RegCloseKey(Handle) = ERROR_SUCCESS;
end;

function WriteOption(const Option: String; Value: Integer): Boolean;
var
Handle: HKey;
begin
Result := False;
if not OpenKey("", Handle) then Exit;
Result := (RegSetValueEx(Handle, PChar(Option), 0, REG_DWORD, @Value, SizeOf(Value)) = ERROR_SUCCESS);
CloseKey(Handle);
end;

function ReadOption(const Option: String; var Res: Integer): Boolean;
var
IntBuffer: Integer;
DataType, BufSize: Integer;
Handle: HKey;
begin
Result := False;
if not OpenKey("", Handle) then Exit;
IntBuffer := 0;
BufSize := SizeOf(IntBuffer);
Result := (RegQueryValueEx(Handle, PChar(Option), nil, @DataType, @IntBuffer, @BufSize) = ERROR_SUCCESS);
CloseKey(Handle);
Res := IntBuffer;
end;


потом где-нить:
<.....>
var
b: Integer;
begin
WriteOption("SuperVar", 123); //сохранить в ключ SuperVar
<....>
if ReadOption("SuperVar", b) then begin
<...>
end else
<ключа не существует>
end;



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

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

Наверх




Память: 0.47 MB
Время: 0.019 c
14-67985
Mishenka
2003-07-03 18:09
2003.07.21
Размер exe файла...


1-67864
johny
2003-07-08 06:44
2003.07.21
печать из компонента WebBrowser


1-67838
Владий
2003-07-07 17:48
2003.07.21
Есть Memo. Нужно скопировать в буфер... (+)


14-67980
Карелин Артем
2003-07-07 11:48
2003.07.21
Буржуйский форум по дельфи. ХОРОШИЙ.


14-68045
Дмитрий К.К.
2003-07-04 06:24
2003.07.21
Именинники 4 июля