//=========================================================================== void Tform_Main::ReadDataFromRegistry() { AnsiString Name; TRegistry *Reg = NULL; try { try { Reg = new TRegistry; AnsiString appName = ExtractFileName(Application->ExeName); appName.SetLength(appName.Length() - 4); Reg->RootKey = HKEY_LOCAL_MACHINE; Reg->OpenKey("Software\\InnalabsUA\\ccg_QFactor", true); DFT_DeltaFreq = Reg->ReadFloat("DFT_DeltaFreq"); DTF_InterpolationPointsCount = Reg->ReadInteger("DTF_InterpolationPointsCount"); FFT_MaxPointsCount = Reg->ReadInteger("FFT_MaxPointsCount"); SoundCardIndex = Reg->ReadInteger("SoundCardIndex"); FreqSoundCardIndex = Reg->ReadInteger("FreqSoundCardIndex"); } catch ( ... ){ Reg->CloseKey(); SaveDataToRegistry(); } } __finally { Reg->CloseKey(); if (Reg != NULL) delete Reg; } }
//--------------------------------------------------------------------------- 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 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; } }