Форум — Ответы ( К темам )
? | Dr.Phoenix: Работа с реестром (20-04-2003 17:34:15) |
Как записать что-нить в реестр, а потом прочитать? | |
Георгий (20-04-2003 18:52:19) | |
TRegIniFile или TRegistryIniFile
| |
dr.phoenix (20-04-2003 18:55:58) | |
а можно пример?
| |
Георгий (20-04-2003 21:18:35) | |
пример из хелпа к конструктору TRegIniFile: 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). #include <Registry.hpp> void __fastcall TForm1::Button1Click(TObject *Sender) { if (NameofKey->Text.IsEmpty() || ValueforKey->Text.IsEmpty()) { ShowMessage("Either the key name or value is missing."); return; } TRegIniFile *Reg = new TRegIniFile("MyApplication"); try { Reg->RootKey = HKEY_LOCAL_MACHINE; // Section to look for within the registry if (!Reg->OpenKey(NameofKey->Text, false)) { if (Application->MessageBox("The specified key does not exist, create it?", "", MB_YESNO) == IDYES) { Reg->CreateKey(NameofKey->Text); if (!Reg->OpenKey(NameofKey->Text, false)) ShowMessage("Error in Opening Created Key"); else Reg->WriteString("Section1", "Value1", ValueforKey->Text); } } else Reg->WriteString("Section1", "Value1", ValueforKey->Text); } __finally { delete Reg; } } |