Главная страница
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.018 c
3-67687
sergt
2003-06-26 16:12
2003.07.21
перегонка данных с таблицы Oracle в dbf


14-68042
Samael6
2003-07-03 21:18
2003.07.21
Dll на Visual C++


7-68078
Uncle Archi
2003-05-06 23:51
2003.07.21
Список процессов.


14-68015
Andryk
2003-07-04 14:20
2003.07.21
Просто флешка


3-67706
Sodom
2003-06-27 11:12
2003.07.21
Ускорение работы с базой.