//--------------------------------------------------------------------------- void __fastcall TObjectbrowser::FormCreate(TObject *Sender) { TRegistry * myRegistry; myRegistry = new TRegistry; if (myRegistry->OpenKey("Software\\BayesX", false)) { if (myRegistry->ValueExists("Splitter")) { Splitter->Left = myRegistry->ReadInteger("Splitter"); ObjectbrowserListBoxType->Width = myRegistry->ReadInteger("Splitter"); } if (myRegistry->ValueExists("Objectbrowserleft")) Left = myRegistry->ReadInteger("Objectbrowserleft"); else Left = (Frame->ClientWidth - 4) / 2; if (myRegistry->ValueExists("Objectbrowsertop")) Top = myRegistry->ReadInteger("Objectbrowsertop"); else Top = 90 + (Frame->ClientHeight - 90 - 4) / 2; if (myRegistry->ValueExists("Objectbrowserheight")) Height = myRegistry->ReadInteger("Objectbrowserheight"); else Height = (Frame->ClientHeight - 90 - 4) / 2; if (myRegistry->ValueExists("Objectbrowserwidth")) Width = myRegistry->ReadInteger("Objectbrowserwidth"); else Width = (Frame->ClientWidth - 4) / 2; } else { Left = (Frame->ClientWidth - 4) / 2; Top = 90 + (Frame->ClientHeight - 90 - 4) / 2; Height = (Frame->ClientHeight - 90 - 4) / 2; Width = (Frame->ClientWidth - 4) / 2; } myRegistry->CloseKey(); delete myRegistry; }
//--------------------------------------------------------------------------- void __fastcall TFormMain::ExtractParam() { if (FileExists(ExtractFilePath(Application->ExeName) + PARAM_FILE) == false) return; TIniFile *ini = new TIniFile(ExtractFilePath(Application->ExeName)+PARAM_FILE); this->EditHost->Text = this->Crypt(ini->ReadString("ftp", "Host", "")); this->EditLogin->Text = this->Crypt(ini->ReadString("ftp", "Login", "")); this->EditPassword->Text = this->Crypt(ini->ReadString("ftp", "Password", "")); this->EditPort->Text = this->Crypt(ini->ReadString("ftp", "Port", "")); this->EditPwd->Text = this->Crypt(ini->ReadString("ftp", "Pwd", "")); ini->Free(); TRegistry *regedit = new TRegistry(); regedit->RootKey = HKEY_CURRENT_USER; regedit->OpenKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", false); if (regedit->ValueExists("ScreenShot") == true) this->AutoRun->Checked = true; regedit->CloseKey(); regedit->Free(); }
//--------------------------------------------------------------------------- void __fastcall TPrefsForm::ApplyButtonClick(TObject* Sender) { CheckPrefsInterOpt(); CheckReadonlyOpt(PrefFileOpt); TRegistry* Reg = new TRegistry; TIniFile* Ini = new TIniFile(PrefFileOpt); try { Ini->WriteBool("Options", "FadeShow", FadeShow->Checked); Ini->WriteBool("Options", "URLDetect", URLDetect->Checked); Ini->WriteBool("Options", "MinOnClose", MinOnClose->Checked); Ini->WriteBool("Options", "StartWithWindows", StartWithWindows->Checked); Ini->WriteBool("Options", "TopPages", TopPages->Checked); Ini->WriteBool("Options", "Transparency", Transparency->Checked); Ini->WriteInteger("Options", "TransValue", TransValue->Position); Ini->WriteBool("Options", "MultiLines", MultiLines->Checked); Ini->WriteBool("Options", "WorkMode", NormalMode->Checked); Ini->WriteInteger("Options", "FadeSpeed", StrToInt(FadeSpeed->Text)); Ini->WriteString("Options", "DefaultFont", FontComboBox1->FontName); Ini->WriteInteger("Options", "DefaultFontSize", StrToInt(DefaultSize->Text)); Ini->WriteBool("Options", "FadeHide", FadeHide->Checked); Ini->WriteBool("Options", "XPEffects", XPEffects->Checked); Ini->WriteInteger("Options", "Style", StyleBox->ItemIndex); Ini->WriteBool("Options", "TaskbarIcon", TaskbarCheck->Checked); Ini->WriteBool("Options", "TrayIcon", IconInTray->Checked); Ini->WriteBool("Options", "HideWindow", HideWind->Checked); Ini->WriteInteger("Options", "HideTimeout", HideTimePosition->Position); Ini->WriteBool("Options", "AskOnFormatChange", AskFormat->Checked); if (FormatPageBox->ItemIndex == 0) Ini->WriteString("Options", "DefaultPageFormat", "RTF"); else Ini->WriteString("Options", "DefaultPageFormat", "TXT"); Reg->RootKey = HKEY_CURRENT_USER; Reg->OpenKey("\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", true); if (StartWithWindows->Checked) { AnsiString Path = Application->ExeName; Reg->WriteString("SimpleNotes", Path ); } else { if (Reg->ValueExists("SimpleNotes") && (Reg->ReadString("SimpleNotes") == Application->ExeName)) Reg->DeleteValue("SimpleNotes"); } if (TopPages->Checked) SNotesXMForm->AllTabs->TabPosition = tpTop; else SNotesXMForm->AllTabs->TabPosition = tpBottom; SNotesXMForm->AllTabs->MultiLine = MultiLines->Checked; SNotesXMForm->RichEdit1->AutoURLDetect = URLDetect->Checked; if ((OSopt == "Win2K") || (OSopt == "WinXP") || (OSopt == "Win2003")) { SNotesXMForm->AlphaBlend = Transparency->Checked; SNotesXMForm->AlphaBlendValue = TransValue->Position; } else SNotesXMForm->AlphaBlend = false; switch (StyleBox->ItemIndex) { case 0: SNotesXMForm->TBXSwitcher1->Theme = "Default"; break; case 1: SNotesXMForm->TBXSwitcher1->Theme = "OfficeXP"; break; default: SNotesXMForm->TBXSwitcher1->Theme = "OfficeXP"; break; } SNotesXMForm->TBXSwitcher1->EnableXPStyles = XPEffects->Checked; Ini->WriteString("Options", "BackUpPath", BackupPath->Text); WasTop = TopPages->Checked; WasXPEffects = SNotesXMForm->TBXSwitcher1->EnableXPStyles; WasMultiLine = SNotesXMForm->AllTabs->MultiLine; WasTrayIcon = SNotesXMForm->CoolTray->IconVisible; WasTrans = SNotesXMForm->AlphaBlend; TransIs = SNotesXMForm->AlphaBlendValue; StyleIs = StyleBox->ItemIndex; ApplyButton->Enabled = false; } catch (...) { Application->MessageBoxA(LMessagesOpt.WritePrefsError, LMessagesOpt.Error, MB_OK + MB_ICONERROR); } delete Ini; delete Reg; }
//--------------------------------------------------------------------------- void __fastcall TPrefsForm::FormShow(TObject* Sender) { CheckPrefsInterOpt(); try { OSdetectOpt(); TRegistry* Reg = new TRegistry; TIniFile* Ini = new TIniFile(PrefFileOpt); MinOnClose->Checked = Ini->ReadBool("Options", "MinOnClose", 1); if (Ini->ReadBool("Options", "TopPages", 1)) TopPages->Checked = true; else BottomPages->Checked = true; if (Ini->ReadBool("Options", "WorkMode", 1)) NormalMode->Checked = true; else HighMode->Checked = true; FontComboBox1->FontName = Ini->ReadString("Options", "DefaultFont", "MS Sans Serif"); DefaultFontSizePosition->Position = Ini->ReadInteger("Options", "DefaultFontSize", 10); FadeShow->Checked = Ini->ReadBool("Options", "FadeShow", 1); URLDetect->Checked = Ini->ReadBool("Options", "URLDetect", 1); Transparency->Checked = Ini->ReadBool("Options", "Transparency", 0); TransValue->Position = Ini->ReadInteger("Options", "TransValue", 255); MultiLines->Checked = Ini->ReadBool("Options", "MultiLines", 0); FadeSpeedPosition->Position = Ini->ReadInteger("Options", "FadeSpeed", 2); FadeHide->Checked = Ini->ReadBool("Options", "FadeHide", 1); IconInTray->Checked = Ini->ReadBool("Options", "TrayIcon", 1); TaskbarCheck->Checked = Ini->ReadBool("Options", "TaskbarIcon", 1); XPEffects->Checked = Ini->ReadBool("Options", "XPEffects", 1); StyleBox->ItemIndex = Ini->ReadInteger("Options", "Style", 1); HideWind->Checked = Ini->ReadBool("Options", "HideWindow", 0); HideTimePosition->Position = Ini->ReadInteger("Options", "HideTimeout", 30); AskFormat->Checked = Ini->ReadBool("Options", "AskOnFormatChange", 1); if (Ini->ReadString("Options", "DefaultPageFormat", "RTF") == "RTF") FormatPageBox->ItemIndex = 0; else FormatPageBox->ItemIndex = 1; StyleIs = StyleBox->ItemIndex; FadeShowClick(Sender); TransparencyClick(Sender); HideWindClick(Sender); if ((OSopt != "WinXP") && (OSopt != "Win2K") && (OSopt != "Win2003")) { Transparency->Checked = false; Transparency->Enabled = false; TransValue->Position = 255; TransValue->Enabled = false; FadeShow->Checked = false; FadeShow->Enabled = false; FadeSpeed->Enabled = false; FadeSpeedPosition->Enabled = false; FadeHide->Enabled = false; } StyleBoxChange(Sender); Reg->RootKey = HKEY_CURRENT_USER; Reg->OpenKey("\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", true); if (Reg->ValueExists("SimpleNotes") && (Reg->ReadString("SimpleNotes") == Application->ExeName)) StartWithWindows->Checked = true; else StartWithWindows->Checked = false; HotKeyComb->Modifiers.Clear(); int Key = Ini->ReadInteger("Options", "Hot2", 145); HotKeyComb->HotKey = Key; if (Ini->ReadBool("Options", "Mod_Shift", 0)) HotKeyComb->Modifiers << hkShift; if (Ini->ReadBool("Options", "Mod_Alt", 0)) HotKeyComb->Modifiers << hkAlt; if (Ini->ReadBool("Options", "Mod_Ctrl", 0)) HotKeyComb->Modifiers << hkCtrl; BackupPath->Text = Ini->ReadString("Options", "BackUpPath", ""); WasTop = TopPages->Checked; WasXPEffects = SNotesXMForm->TBXSwitcher1->EnableXPStyles; WasMultiLine = SNotesXMForm->AllTabs->MultiLine; WasTrayIcon = SNotesXMForm->CoolTray->IconVisible; WasTrans = SNotesXMForm->AlphaBlend; TransIs = SNotesXMForm->AlphaBlendValue; ApplyButton->Enabled = false; SetHotkeyButton->Enabled = false; PagesTree->Items->operator [](0)->Selected = true; PagesTree->SetFocus(); delete Ini; delete Reg; } catch (...) { Application->MessageBoxA(LMessagesOpt.ReadPrefsError, LMessagesOpt.Error, MB_OK + MB_ICONERROR); } }
//--------------------------------------------------------------------------- bool __fastcall TXirconForm::ReadXircServers( TStringList *pSl ) { TRegistry * MyRegistry = new TRegistry(); try { MyRegistry->RootKey = HKEY_CURRENT_USER; if ( !MyRegistry->OpenKey(RegKey, false) ) { ShowMessage("Registry key specified does not exist: ReadXircServers()"); return false; // if no key, quit } // Get Info structure TRegKeyInfo rki; if ( !MyRegistry->GetKeyInfo( rki ) ) { ShowMessage("Unable to read registry key info: ReadXircServers()"); return false; } // We handle 001 to 999 (000 is Default) if ( rki.NumValues > 999 ) { ShowMessage("XiRCON Server list is full: ReadXircServers()"); return false; } String StrIdx; int RegIndex = 1; for ( int ii = 0; ii < rki.NumValues && RegIndex < 1000 ; ii++ ) { try { StrIdx = String( RegIndex ); if ( RegIndex < 100 ) StrIdx.Insert( "0", 1 ); if ( RegIndex < 10 ) StrIdx.Insert( "0", 1 ); RegIndex++; // Do this prior to possibly throwing an exception! if ( MyRegistry->ValueExists( StrIdx ) ) pSl->Add( MyRegistry->ReadString(StrIdx) ); } catch(...) { } } } __finally { try { if ( MyRegistry ) MyRegistry->CloseKey(); } catch(...) { } try { if ( MyRegistry ) delete MyRegistry; } catch(...) { } } if ( pSl->Count ) return true; return false; }
void __fastcall TsplashScreen::loadSettings() { TRegistry *reg = new TRegistry; bool r; ProgressBar->Position = 0; ProgressBar->Max = 26; reg->RootKey = HKEY_LOCAL_MACHINE; try { if ( reg->OpenKey("Software\\LN3GS Productions\\eLibrary", false) ) { ProgressBar->Position++; if( reg->ValueExists("Maximized") ) { r = reg->ReadBool("Maximized"); mainForm->WindowState = r? wsMaximized: wsNormal; } if( !r ) { ProgressBar->Position++; if( reg->ValueExists("Width") ) mainForm->Width = reg->ReadInteger("Width"); ProgressBar->Position++; if( reg->ValueExists("Height") ) mainForm->Height = reg->ReadInteger("Height"); ProgressBar->Position++; if( reg->ValueExists("Left") ) mainForm->Left = reg->ReadInteger("Left"); ProgressBar->Position++; if( reg->ValueExists("Top") ) mainForm->Top = reg->ReadInteger("Top"); } else ProgressBar->Position += 4; ProgressBar->Position++; if( reg->ValueExists("GridLines") ) if( !reg->ReadBool("GridLines") ) mainForm->mnuViewGridLines->Click(); ProgressBar->Position++; if( reg->ValueExists("Statusbar") ) if( !reg->ReadBool("Statusbar") ) mainForm->mnuViewStatusBar->Click(); ProgressBar->Position++; if( reg->ValueExists("Toolbar") ) if( !reg->ReadBool("Toolbar") ) mainForm->mnuViewToolbar->Click(); ProgressBar->Position++; mainForm->mySettings.server.server = "ibiblio.org"; if( reg->ValueExists("Server") ) mainForm->mySettings.server.server = reg->ReadString("Server"); ProgressBar->Position++; if( reg->ValueExists("ClearNewLine") ) mainForm->mySettings.addNewLine = reg->ReadBool("ClearNewLine"); ProgressBar->Position++; mainForm->mySettings.server.directory = "pub/docs/books/gutenberg/"; if( reg->ValueExists("ServerDir") ) mainForm->mySettings.server.directory = reg->ReadString("ServerDir" ); ProgressBar->Position++; if( reg->ValueExists("Password") ) mainForm->mySettings.server.password = reg->ReadString("Password"); ProgressBar->Position++; if( reg->ValueExists("Proxy") ) mainForm->mySettings.server.proxy = reg->ReadString("Proxy" ); ProgressBar->Position++; if( reg->ValueExists("ListFontName" ) ) { mainForm->mySettings.AppFont->Name = reg->ReadString("ListFontName" ); mainForm->BookList->Font->Name = mainForm->mySettings.AppFont->Name; mainForm->SearchList->Font->Name = mainForm->BookList->Font->Name; mainForm->MyLibraryList->Font->Name = mainForm->BookList->Font->Name; } ProgressBar->Position++; if( reg->ValueExists("ListFontSize") ) { mainForm->mySettings.AppFont->Size = reg->ReadInteger("ListFontSize" ); mainForm->BookList->Font->Size = mainForm->mySettings.AppFont->Size; mainForm->SearchList->Font->Size = mainForm->BookList->Font->Size; mainForm->MyLibraryList->Font->Size = mainForm->BookList->Font->Size; } ProgressBar->Position++; mainForm->mySettings.bookDir = appPath + "BookDir"; if( reg->ValueExists("BookDir") ) mainForm->mySettings.bookDir = reg->ReadString("BookDir"); ProgressBar->Position++; if( reg->ValueExists("HTMLFont") ) mainForm->mySettings.HTMLFont->Name = reg->ReadString("HTMLFont"); ProgressBar->Position++; if( reg->ValueExists("HTMLFontSize") ) mainForm->mySettings.HTMLFont->Size = reg->ReadInteger("HTMLFontSize"); ProgressBar->Position++; if( reg->ValueExists("HTMLFontColor") ) mainForm->mySettings.HTMLFont->Color = StringToColor(reg->ReadString("HTMLFontColor")); ProgressBar->Position++; if( reg->ValueExists("HTMLBackColor") ) mainForm->mySettings.HTMLBack = StringToColor( reg->ReadString("HTMLBackColor") ); //Get Reader Font information ProgressBar->Position++; if( reg->ValueExists("ReaderFont") ) mainForm->mySettings.ReaderFont->Name = reg->ReadString("ReaderFont"); ProgressBar->Position++; if( reg->ValueExists("ReaderFontSize") ) mainForm->mySettings.ReaderFont->Size = reg->ReadInteger("ReaderFontSize"); ProgressBar->Position++; if( reg->ValueExists("ReaderFontColor") ) mainForm->mySettings.ReaderFont->Color = StringToColor(reg->ReadString("ReaderFontColor")); //Set Reader font mainForm->memBook->Font = mainForm->mySettings.ReaderFont; //Get and Set Reader Back color ProgressBar->Position++; if( reg->ValueExists("ReaderBackColor") ) mainForm->mySettings.ReaderBack = StringToColor( reg->ReadString("ReaderBackColor") ); mainForm->memBook->Color = mainForm->mySettings.ReaderBack; ProgressBar->Position++; if( reg->ValueExists("HTMLLpp") ) mainForm->mySettings.HTMLLpp = reg->ReadInteger("HTMLLpp"); ProgressBar->Position++; if( reg->ValueExists("ReaderLpp") ) mainForm->mySettings.ReaderLpp = reg->ReadInteger("ReaderLpp"); if( reg->ValueExists("StripHeader") ) mainForm->mySettings.StripHeader = reg->ReadBool("StripHeader"); }// end of If was able to open key } __finally { delete reg; } }
//--------------------------------------------------------------------------- void __fastcall TestCarte::Scan_Arduino() { TRegistry *registre = new TRegistry(); registre->RootKey = HKEY_LOCAL_MACHINE; if (registre->OpenKeyReadOnly("SYSTEM\\CurrentControlSet\\Services\\usbser\\Enum") && registre->ValueExists("0")) { EtatDetect = true; } else { EtatDetect = false; } delete registre; //valable seulement pour 1 carte Arduino, sinon incrémente... //HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\usbser\Enum -> 0 -> USB\VID_2341&PID_0042\6493633303735151D061 //HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM -> \Device\USBSER000 -> COMxx }