Exemple #1
0
void __fastcall TMainForm::LoadFromRegistry ()
{
  m_use_date_interval = false;

  TRegistry * reg = new TRegistry (KEY_READ);
  try
  {
    reg->RootKey = HKEY_LOCAL_MACHINE;
    reg->OpenKey ("\\SOFTWARE\\Gis center\\Journal", true);

    m_use_date_interval = reg->ReadBool("UseDateInterval");
    m_date_begin = reg->ReadDate("DateBegin");
    m_date_end = reg->ReadDate("DateEnd");

    m_auto_login = reg->ReadBool("AutoLogin");
    m_user_name = reg->ReadString("UserName");
    m_password = reg->ReadString("Password");
    m_server = reg->ReadString("Server");
    m_notification_days = StrToInt (reg->ReadString ("NotifyInterval"));
  }
  __finally
  {
    //delete reg;
    safe_delete (reg);
  }
}
Exemple #2
0
//---------------------------------------------------------------------------
AnsiString __fastcall GetMatlab6Root(void)
{
   AnsiString S = "";
   __TRY
   TRegistry *RR = new TRegistry();
   try
    {
    // Для Matlab 6.5

     RR->RootKey = HKEY_CLASSES_ROOT;
     if (RR->OpenKey("\\Matlab.Application.Single.6\\CLSID",false))
       S = RR->ReadString("");
     if (RR->OpenKey("\\CLSID\\"+S+"\\LocalServer32",false))
       S = RR->ReadString("");
     int ps = S.AnsiPos("matlab.exe");
     if (ps) {
      S = S.SubString( 1, ps-2);
     // S содержит размещение matlab.exe (полный путь)
      S = ExtractFileDir(S);
      S = ExtractFileDir(S);
      }
    }
      __finally {
      delete RR;
      }
  if (!DirectoryExists(S)) {
    S = "";
    }
  __CATCH
  return S;
}
void __fastcall TRegAssociationsForm::FormActivate(TObject *Sender)
{
  ValueListEditorAssoc->Strings->Clear();

  TRegistry * reg = new TRegistry();
  try
  {
    reg->RootKey = HKEY_LOCAL_MACHINE;

    reg->OpenKey("\\SOFTWARE\\Gis center\\Journal\\Associations", true);

    TStringList * val = new TStringList;
    try
    {
      reg->GetValueNames(val);
      for (int i = 0; i < val->Count; i++)
          ValueListEditorAssoc->InsertRow (val->Strings[i], reg->ReadString(val->Strings[i]), true);
    }
    __finally
    {
      safe_delete (val);
//      delete val;
    }

    reg->CloseKey();
  }
  __finally
  {
    safe_delete (reg);
//    delete reg;
  }
}
Exemple #4
0
//---------------------------------------------------------------------------
AnsiString __fastcall Regread(AnsiString folder,AnsiString Key,int mode)
{
 AnsiString S="";
 int p,p1;
 TRegistry *Registry = new TRegistry;
 try
 {
  Registry->RootKey = HKEY_LOCAL_MACHINE;
  if(Registry->OpenKeyReadOnly(folder))
  {
   if(mode==0)
    S = Registry->ReadString(Key);
   if(mode==1)
    Registry->WriteString("ServerN",Key);
   if(mode==2)
	Registry->WriteString("DB",Key);

  }
  Registry->CloseKey();
 }
 __finally
 {
  delete Registry;
 }
 return S;
}
int init()
{
  OutputDebugString("RPCInterface init");
TRegistry * reg;
AnsiString str;
  if (frmPluginMain == NULL)
  {
    try
    {
      // pass on the provided parameters
	  // this gets better behaviour for VCL dlls
      Application->Handle = plugin.hwndParent;
      frmPluginMain = new TfrmPluginMain(Application);
      try
      {
        // set parent handle
        reg = new TRegistry();
        reg->OpenKey("software\\PMMSoft\\Winamp controller\\server settings", true);
        str = reg->ReadString("Visible");
        if (str.LowerCase() == "true")
          frmPluginMain->Show();
      }
      __finally
      {
        delete reg;
      }
    }
    catch (...)
    {
      delete frmPluginMain;
      frmPluginMain = NULL;
    }
  }
  return 0;
}
Exemple #6
0
void __fastcall Tampcfgform::FormCreate(TObject *Sender)
{
	TRegistry *myreg;

    myreg = new TRegistry();
    myreg->RootKey = HKEY_LOCAL_MACHINE;
    myreg->OpenKey( "Software\\Ampoliros", true );

    if ( strlen( myreg->ReadString( "PRIVATE_TREE" ).c_str() ) )
    {
    	privatetree->Text = myreg->ReadString( "PRIVATE_TREE" );
    	publictree->Text = myreg->ReadString( "PUBLIC_TREE" );
        sitestree->Text = myreg->ReadString( "SITES_TREE" );

    	privatetree->Enabled = false;
        publictree->Enabled = false;
        sitestree->Enabled = false;

        override->Enabled = true;
Exemple #7
0
void __fastcall TForm1::FormShow(TObject *Sender)
{

SG->Cells[0][0] ="正常项目";
SG->Cells[1][0] = "目前注册表项目";


TRegistry *reg = new TRegistry;
try
{
reg->RootKey = HKEY_CLASSES_ROOT;
reg->OpenKey(".exe",false);


SG->Cells[0][1] = "位置:HKEY_CLASSES_ROOT\\.exe 键值:exefile";
SG->Cells[1][1] = reg->ReadString("");
reg->CloseKey();

SG->Cells[0][2] =  "位置:HKEY_CLASSES_ROOT\\exefile\\shell\\open\\command 键值:\"%1\" %*";
reg->OpenKey("exefile\\shell\\open\\command\\",false);
SG->Cells[1][2] = reg->ReadString("");
reg->CloseKey() ;

if (SG->Cells[1][1]  != "exefile" | SG->Cells[1][2] != "\"%1\" %*" )
        {
        SG->Color = RGB(255,0,0);
        Button1->Enabled = true;
        ShowMessage("发现注册表设置异常,请点击修复进行修改!");
        }
else
{
ShowMessage("所有设置都是正常的,如果还是有问题,\n请参照说明的键值在注册表中手动修复。");
}
}
  __finally
  {
    delete reg;
  }



}
TStringList* TCommThread::GetAvailableDevicesNames(bool IncludeSerial, bool IncludeParallel, TStringList * AvaiableDevicesNames)
{
        TRegistry       *Registro = new TRegistry();
        TStringList     *StringsTemp = new TStringList();
        int Indice;
        if (AvaiableDevicesNames!=NULL)
                AvaiableDevicesNames->Clear();
        else
                AvaiableDevicesNames = new TStringList();

        Registro->RootKey=HKEY_LOCAL_MACHINE;

        if(IncludeSerial==true)
        {
                StringsTemp->Clear();

                Registro->OpenKey("hardware\\devicemap\\serialcomm",false);
                Registro->GetValueNames(StringsTemp);

                for (Indice=0;Indice<StringsTemp->Count;Indice++)
                        AvaiableDevicesNames->Add(Registro->ReadString(StringsTemp->Strings[Indice]));
                Registro->CloseKey();
        }

        if(IncludeParallel==true)
        {
                StringsTemp->Clear();

                Registro->OpenKey("hardware\\devicemap\\parallel ports",false);
                Registro->GetValueNames(StringsTemp);

                for (Indice=0;Indice<StringsTemp->Count;Indice++)
                        AvaiableDevicesNames->Add(ExtractFileName(Registro->ReadString(StringsTemp->Strings[Indice])));
                Registro->CloseKey();
        }
        AvaiableDevicesNames->Sort();
        delete Registro;
        delete StringsTemp;
        return AvaiableDevicesNames;

}
Exemple #9
0
//---------------------------------------------------------------------------
// Common functions
//---------------------------------------------------------------------------
AnsiString __fastcall GetRegistryValue(AnsiString KeyName, AnsiString Value)
{
  AnsiString S = "";
  __TRY
  TRegistry *Registry = new TRegistry;
  try {
    Registry->RootKey = HKEY_CLASSES_ROOT; //HKEY_LOCAL_MACHINE;
    Registry->OpenKey(KeyName,false);
    S = Registry->ReadString(Value);
  } __finally {
    delete Registry;
    }
  __CATCH
  return S;
}//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
	String sKeyName = "Software\\DD2\\TEST";// キーの名前
	String sValue;// キーの値
	TRegistry *Registry = new TRegistry(KEY_ALL_ACCESS);
	try {
		Registry->RootKey = HKEY_CURRENT_USER;
		Registry->OpenKey(sKeyName,true);// 第二引数がtrueのとき、なければ作成 falseのとき、なくても作成しない
		// 読み込み
		sValue = Registry->ReadString("HOGE");
		Memo1->Lines->Add(sValue);
		Registry->CloseKey();
	}
	catch(...) {
		ShowMessage("レジストリの処理に失敗しました");
	}
	delete Registry;

}
Exemple #11
0
//---------------------------------------------------------------------------
String CUtilites::GetRegInfoS(String RegKey, String KeyName)
{
    String RetVal = "";
    TRegistry *MyRegistry = new TRegistry();
    MyRegistry->RootKey = HKEY_LOCAL_MACHINE;
    try
    {
       if(MyRegistry->OpenKey(RegKey, false))
       {
          RetVal = MyRegistry->ReadString(KeyName);
          MyRegistry->CloseKey();
       }
    }
    catch(ERegistryException &E)
    {
       Application->MessageBoxA(E.Message.c_str(), "Error", MB_OK);
    }
    delete MyRegistry;
    return RetVal;
}
void __fastcall TfrmPluginMain::FormCreate(TObject *Sender)
{
    const BufferSize = 32;		//Buffer max size
    char Computername[BufferSize];     // pointer to system information string
    DWORD cchBuff;       // size of computer or user name
    bool success;
    TRegistry * reg;

    Application->OnException = AppException;


    try
    {
        reg = new TRegistry();
        reg->OpenKey("software\\PMMSoft\\Winamp controller\\server settings", true);
        AnsiString EndPoint = reg->ReadString("EndPoint");
        // issue #3
        success = true;
    }
    __finally
    {
        delete reg;
    }

    /*
    Get the computer name. */
    cchBuff = 32;
    if (success)
    {
        success = success && GetComputerName(Computername, &cchBuff);
    }

    if (success)
    {
        sbrMain->Panels->Items[1]->Text = AnsiString("name: ") + Computername;
        CreateThread();
    }

}
//===========================================================================
//===========================================================================
//===========================================================================
//===========================================================================
void AddNewFileToMainMenu(TPopupMenu *PopupMenu, AnsiString FileName, TNotifyEvent NotifyEvent)
{
  TRegistry *Reg = new TRegistry;
  bool      FirstInput = false;
  bool      FileExist  = false;
  int       Counter    = 0;
  int       posFileNameInMenu = -1;
  AnsiString appName = ExtractFileName(Application->ExeName); appName.SetLength(appName.Length() - 4);

  try {
     Reg->RootKey = HKEY_LOCAL_MACHINE;  /// ---- Находитться в Uses Windows
     Reg->OpenKey("Software\\Digital Systems & Technologies\\" + appName, true); //create a new key >> .ext
     //-------------------
     if (FileName == "Load") {
            for ( int i = 0; i < CountFileName; i++){
              FileNameStackArray[i] = "";
              FileNameStackArray[i] = Reg->ReadString("FileName"+IntToStr(i+1));
              if (FileNameStackArray[i] != "") {
                 Counter = Counter + 1;
                 addMenuItem (Counter, PopupMenu, "&"+IntToStr(Counter) + ". " + GetShortFileName(FileNameStackArray[i]), NotifyEvent);
                 FirstInput = true;
              }
            }

            if (FirstInput) addMenuItem (Counter + 1,PopupMenu,"-", NULL);
     } else {
            // --- Проверка на повтор файла -----------
            for ( int i = 0; i < CountFileName; i++)
               if (FileName == FileNameStackArray[i]) {
                  FileExist         = true;
                  FileNameStackArray[i]  = "";
                  posFileNameInMenu = i;
               }
            // -------- Если файл уже существует то удаляем его из списка, сортируем список
            if (FileExist) {
               for ( int i = posFileNameInMenu; i < CountFileName - 1; i++ ) {
                    FileNameStackArray[i] = FileNameStackArray[i+1];
               }
               FileNameStackArray[CountFileName - 1] = "";
            }
            // ----- Добавляем в "Стек" ---------
            for ( int i = CountFileName - 1; i > 0; i--)
                if (FileNameStackArray[i-1].data() != NULL)
                    FileNameStackArray[i] = FileNameStackArray[i-1];
            FileNameStackArray[0] = FileName;

            // ---- Удаляю все файлы с менюхи  ---------
            for ( int i = PopupMenu->Items->Count-1; i >= 0; i--)
                 if (PopupMenu->Items->Items[i]->Name[1] == 'F')
                      delete PopupMenu->Items->Items[i];

            // ---- Добавляю новые файлы в менюху ------
            Counter = 0;
            for ( int i = 0; i < CountFileName - 1; i++ ) {
              if (FileNameStackArray[i] != "") {
                 Counter = Counter + 1;
                 addMenuItem (Counter, PopupMenu, "&" + IntToStr(Counter) + ". " + GetShortFileName(FileNameStackArray[i]), NotifyEvent);
              }
            }
            // ---- Добавляю черту ------
            addMenuItem (Counter + 1,PopupMenu,"-", NULL);
     }

     // ---- Записываю в Реестр -------
     for ( int i = 0; i < CountFileName; i++)
        Reg->WriteString("FileName" + IntToStr(i+1), FileNameStackArray[i]);
     //-------------------
     Reg->CloseKey();
  } __finally {
    delete Reg;
  }
}
Exemple #14
0
//---------------------------------------------------------------------------
void TRtfConverterList::GetConverterList(HKEY regRoot, AnsiString regPath,
  AnsiString appName, bool import)
{
  // allocate string list for subkeys
  TStringList* subKeys = new TStringList();

  // Registry key path and data value names
  AnsiString sRegPath = regPath;
  AnsiString sName("Name");
  AnsiString sExt("Extensions");
  AnsiString sPath("Path");

  // modify Registry key path for import or export
  if (import) sRegPath += AnsiString("Import");
  else sRegPath += AnsiString("Export");

  // allocate a Registry object
  TRegistry* reg = new TRegistry();

  try {
    // open Registry key and get subkeys
    reg->RootKey = regRoot;
    reg->OpenKey(sRegPath, false);
    reg->GetKeyNames(subKeys);
    reg->CloseKey();

    // for each subkey
    for (int i = 0; i < subKeys->Count; i++) {
      AnsiString currKey, name, ext, path;

      // append it to the import/export key
      currKey = sRegPath + AnsiString("\\") + subKeys->Strings[i];

      // open that key and retrieve "Name," "Path", & "Extensions" values
      try {
        reg->OpenKey(currKey, false);
        name = reg->ReadString(sName);
        path = reg->ReadString(sPath);
        AnsiString tempExt = reg->ReadString(sExt);

        // extensions are returned as a space-delimited, null-terminated
        // string; parse extensions and format as filters
        char* s = tempExt.c_str();
        while (*s) {
          AnsiString temp = NextExt(s);
          if (!temp.Length()) continue;
          if (ext.Length()) ext += ";";
          ext += AnsiString("*.") + temp;
          }
        }
      // catch errors and continue
      catch (...) {}

      // close the subkey
      reg->CloseKey();

      // duplicates are possible -- look through the descriptions
      // and, if a match is found, compare the library paths, extensions,
      // and format classes... if all are the same as the existing entry,
      // then skip this one.
      bool skipIt = false;
      for (int j = 0; j < FRawDescription->Count; j++)
        if (!(FRawDescription->Strings[j].AnsiCompareIC(name)) &&
          !(LibraryPath->Strings[j].AnsiCompareIC(path)) &&
          !(FormatClass->Strings[j].AnsiCompareIC(subKeys->Strings[i])) &&
          !(Filters->Strings[j].AnsiCompareIC(ext)))
          skipIt = true;

      // and add the values to the string lists
      if (!skipIt && name.Length() && ext.Length() && path.Length()) {
        AnsiString rawName = name;
        if (appName.Length()) name += AnsiString(" - ") + appName;
        int ndx = Description->Add(name);
        FRawDescription->Insert(ndx, rawName);
        LibraryPath->Insert(ndx, path);
        FormatClass->Insert(ndx, subKeys->Strings[i]);
        Filters->Insert(ndx, ext);
        }
      }
    }
  // ignore errors
  catch (...) {}

  // free local storage
  delete reg;
  delete subKeys;
}
Exemple #15
0
void __fastcall TMainForm::ButtonLoadClick(TObject *Sender)
{
  if (OraQueryAllJournal->RecordCount == 0 || OraQueryDocs->RecordCount == 0)
  {
    ShowMessage ("Не выбран файл для загрузки !");
    return;
  }

  Screen->Cursor = crHourGlass;

  AnsiString temp_dir;
  TRegistry * reg = new TRegistry (KEY_READ);
  try
  {
    reg->RootKey = HKEY_LOCAL_MACHINE;
    reg->OpenKey ("\\SOFTWARE\\Gis center\\Journal", true);

    temp_dir = reg->ReadString ("TempDir");
  }
  __finally
  {
    safe_delete (reg);
//    delete reg;
  }

  if (temp_dir.IsEmpty())
  {
    ShowMessage ("Не задана временная директория для выгрузки файлов !");
    Screen->Cursor = crDefault;
    return;
  }

  ProgressForm->Show();

  AnsiString fn;

  TOraQuery * docQuery = new TOraQuery (this);
  try
  {
    docQuery->SQL->Text = "SELECT DOC_NAME, DOC_TEXT FROM " + m_shema + "." +
                           m_blob_table + " WHERE " + m_blob_primary_key + " = " +
                           OraQueryDocs->Fields->FieldByName(m_blob_primary_key)->AsString;
    docQuery->Open();
    docQuery->First();

    fn = docQuery->Fields->FieldByName ("DOC_NAME")->AsString;
    TBlobField * blob = (TBlobField*)(docQuery->Fields->FieldByName("DOC_TEXT"));
    blob->SaveToFile (temp_dir + "\\" + fn);

    docQuery->Close();
  }
  __finally
  {
    safe_delete (docQuery);
    //delete docQuery;
  }

  m_loading_docs [OraQueryDocs->Fields->FieldByName(m_blob_primary_key)->AsInteger] = temp_dir + "\\" + fn;
  ButtonSaveDoc->Enabled = true;

  Files.insert(temp_dir + "\\" + fn);

  // Проверка ассоциации
  AnsiString path;

  reg = new TRegistry (KEY_READ);
  try
  {
    reg->RootKey = HKEY_LOCAL_MACHINE;
    reg->OpenKey ("\\SOFTWARE\\Gis center\\Journal\\Associations", true);

    path = reg->ReadString (ExtractFileExt (fn).Delete(1, 1));

    reg->CloseKey();
  }
  __finally
  {
    safe_delete (reg);
    //delete reg;
  }

  if (!path.IsEmpty())
  {
    STARTUPINFO si = {sizeof (si)};
    PROCESS_INFORMATION pi;

    AnsiString dir = GetCurrentDir();
    SetCurrentDir (temp_dir);
    if (CreateProcess (NULL, ("\"" + path + "\" \"" +fn + "\"").c_str(), 0, 0, FALSE, 0,0,0, &si, &pi))
    {
      CloseHandle (pi.hThread);
      CloseHandle (pi.hProcess);
    }
    SetCurrentDir (dir);
  }
  else
  {
    ShellExecute(0, "open", AnsiString (temp_dir + "\\" + fn).c_str(), NULL, NULL, SW_SHOWNORMAL);
  }

  ProgressForm->Close();

  Screen->Cursor = crDefault;
}
Exemple #16
0
//---------------------------------------------------------------------------
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;
}
Exemple #17
0
//---------------------------------------------------------------------------
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);
  }
}
Exemple #18
0
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;   }
}
//---------------------------------------------------------------------------
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;
}