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

Вниз

Пример ключа в реестр   Найти похожие ветки 

 
Pi:=3.14...   (2008-05-31 12:10) [0]

Пожалуйста. Напишите пример кода как добавить ключь в реестр.Заранее спасибоnull


 
engine ©   (2008-05-31 12:19) [1]

This OnClick event handler adds the value specified in the ValueforKey edit box to the registry key specified by the NameofKey edit box. If the named key does not already exist, it creates one. (Note that if you don’t want to give the user a choice, this could be accomplished more simply by setting the CanCreate parameter of the OpenKey call to true).

procedure TForm1.Button1Click(Sender: TObject);
var
 Reg: TRegIniFile;
begin
 if Length(NameofKey.Text) or Length(ValueforKey.Text) <=0 then
   Showmessage("Either the key name or value is missing.")
 else begin
   Reg:=TRegIniFile.Create("MyApp");
   try
     Reg.RootKey:=HKey_Local_Machine; // Section to look for within the registry
     if not Reg.OpenKey(NameofKey.Text,False) then
       if MessageDlg("The specified key does not exist, create it?"

                ,Mtinformation,[mbYes,mbNo],0)=mryes then
       begin
         Reg.CreateKey(NameofKey.Text);
         if not Reg.OpenKey(NameofKey.Text,False) then
           ShowMessage("Error in Opening Created Key")
         else
           Reg.WriteString("Main Section","Value1",ValueForKey.Text);
       end
    else
      Reg.WriteString("Main Section","Value1",ValueForKey.Text);
   finally

     Reg.Free;
   end;
 end;
end;


 
Loginov Dmitry ©   (2008-05-31 12:34) [2]

>     if not Reg.OpenKey(NameofKey.Text,False) then
>       if MessageDlg("The specified key does not exist,
> create it?"


С чего такой однозначный вывод: "The specified key does not exist"?


 
engine ©   (2008-05-31 12:49) [3]

> [2] Loginov Dmitry ©   (31.05.08 12:34)

Этот вопрос к разработчикам справки Delphi


 
LightRipple ©   (2008-05-31 13:05) [4]

> [3] engine ©   (31.05.08 12:49)
> Этот вопрос к разработчикам справки Delphi

Это где ты такую "справку Delphi" нашел ?


 
engine ©   (2008-05-31 13:23) [5]

Delphi 7


 
LightRipple ©   (2008-05-31 13:27) [6]

> [5] engine ©   (31.05.08 13:23)
> Delphi 7

> Offtop
Что-то меня за сегодня уже второй раз в справку Delphi 7 посылают.
Видать к дождю :) Нет у меня на компьютере Delphi 7 - не могу проверить :)


 
Leonid Troyanovsky ©   (2008-05-31 15:33) [7]


> engine ©   (31.05.08 12:49) [3]

> Этот вопрос к разработчикам справки Delphi

>          Reg.CreateKey(NameofKey.Text);
>          if not Reg.OpenKey(NameofKey.Text,False) then
>            ShowMessage("Error in Opening Created Key")

А это из какой справки?

Может, все же
if not Reg.OpenKey(NameofKey.Text, True) then
 ShowMessage("The registry key could not be opened or created.")

--
Regards, LVT.


 
имя   (2008-06-03 23:10) [8]

Удалено модератором


 
имя   (2008-06-04 00:26) [9]

Удалено модератором



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

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

Наверх




Память: 0.48 MB
Время: 0.024 c
15-1209458145
inew
2008-04-29 12:35
2008.06.29
Tabel1.filter


2-1212170826
VovKul
2008-05-30 22:07
2008.06.29
Как поместить шрифт в ресурс...


15-1210451486
Германн
2008-05-11 00:31
2008.06.29
Любимая операционная система NASA


15-1210707407
Маэстро
2008-05-13 23:36
2008.06.29
Опрос (не программерский, относительно)


2-1212487305
AlekseyB
2008-06-03 14:01
2008.06.29
QReport