Главная страница
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.018 c
2-1212331409
snake-as
2008-06-01 18:43
2008.06.29
Использовать слово из TWebBrowser


4-1192474636
alek
2007-10-15 22:57
2008.06.29
Рисование в, к примеру, Paint


2-1212375734
snake-as
2008-06-02 07:02
2008.06.29
MediaPlayer


4-1192188544
arab
2007-10-12 15:29
2008.06.29
Арабский язык &amp; Delphi


3-1201096350
Gklbery
2008-01-23 16:52
2008.06.29
динамический use