Exemple #1
0
//===========================================================================
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;
    }
}
Exemple #2
0
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
//修复代码
TRegistry *reg = new TRegistry;
try
{
reg->RootKey = HKEY_CLASSES_ROOT;
reg->OpenKey(".exe",true);
reg->WriteString("","exefile");
reg->CloseKey();

reg->OpenKey("exefile\\shell\\open\\command\\",true);
reg->WriteString ("","\"%1\" %*");
reg->CloseKey() ;

ShowMessage("所有错误已经成功修复!");
SG->Color = clWindow;
Button1->Enabled = false;
//Form1->DoHide ();
Form1->DoShow ();
}
  __finally
  {
    delete reg;
  }
}
Exemple #3
0
void __fastcall TFormMain::AutoRunClick(TObject *Sender)
{
	TRegistry *regedit = new TRegistry();
	regedit->RootKey = HKEY_CURRENT_USER;
	regedit->OpenKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", false);
	if (this->AutoRun->Checked == true) {
		try {
			regedit->WriteString("ScreenShot", Application->ExeName);
			ShowMessage("Given program will be launched at start computer");
		} catch (Exception *e) {
			ShowMessage("Error: I can not remove autorun");
			DebugOutput(e->Message);
		}
	} else {
		try {
			regedit->DeleteValue("ScreenShot");
			ShowMessage("Autorun was deleted");
		} catch (Exception *e) {
			ShowMessage("Error: i Can't delete a autorun");
            DebugOutput(e->Message);
		}
	}
	regedit->CloseKey();
	regedit->Free();
}
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;
}
void __fastcall TRegAssociationsForm::ButtonExitClick(TObject *Sender)
{
  TRegistry * reg = new TRegistry ();
  try
  {
    reg->RootKey = HKEY_LOCAL_MACHINE;

    if (reg->KeyExists("\\SOFTWARE\\Gis center\\Journal\\Associations"))
        reg->DeleteKey("\\SOFTWARE\\Gis center\\Journal\\Associations");

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

    for (int row = 1; row < ValueListEditorAssoc->RowCount; row++)
    {
      reg->WriteString (ValueListEditorAssoc->Cells [0][row],
                        ValueListEditorAssoc->Cells [1][row]);
    }

    reg->CloseKey();
  }
  __finally
  {
    safe_delete (reg);
    //delete reg;
  }
}
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 #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;

}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
	String sKeyName = "Software\\DD2\\TEST";// キーの名前
	TRegistry *Registry = new TRegistry(KEY_ALL_ACCESS);
	try {
		Registry->RootKey = HKEY_CURRENT_USER;
		Registry->OpenKey(sKeyName,true);// 第二引数がtrueのとき、なければ作成 falseのとき、なくても作成しない
		// 書き込み
		Registry->WriteString("HOGE","TAMA");
		Registry->CloseKey();
	}
	catch(...) {
		ShowMessage("レジストリの処理に失敗しました");
	}
	delete Registry;
}
Exemple #10
0
//---------------------------------------------------------------------------
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 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 #12
0
//---------------------------------------------------------------------------
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;

}
Exemple #13
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;
}
Exemple #14
0
//--------------------------------------------------------------------------
bool CUtilites::SetRegInfoS(String RegKey, String KeyName, String Value)
{
    bool RetVal = false;
    TRegistry *MyRegistry = new TRegistry();
    MyRegistry->RootKey = HKEY_LOCAL_MACHINE;
    try
    {
       if(MyRegistry->OpenKey(RegKey, true))
       {
          MyRegistry->WriteString(KeyName, Value);
          MyRegistry->CloseKey();
          RetVal = true;
       }
    }
    catch(ERegistryException &E)
    {
       Application->MessageBoxA(E.Message.c_str(), "Error", MB_OK);
    }
    delete MyRegistry;
    return RetVal;
}
Exemple #15
0
//===========================================================================
void Tform_Main::SaveDataToRegistry()
{
    TRegistry *Reg = NULL;
    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);

        Reg->WriteFloat("DFT_DeltaFreq", DFT_DeltaFreq);

        Reg->WriteInteger("DTF_InterpolationPointsCount", DTF_InterpolationPointsCount);
        Reg->WriteInteger("FFT_MaxPointsCount", FFT_MaxPointsCount);
        Reg->WriteInteger("SoundCardIndex", SoundCardIndex);
        Reg->WriteInteger("FreqSoundCardIndex", FreqSoundCardIndex);

    } __finally {
        Reg->CloseKey();
        if (Reg != NULL)
            delete Reg;
    }
}
Exemple #16
0
//---------------------------------------------------------------------------
void __fastcall TMainForm::actRegisterExecute(TObject *Sender)
{
  try
  {
    TRegistry *reg = new TRegistry;
    reg->RootKey = HKEY_CLASSES_ROOT;
    reg->OpenKey(".avm", true);
    reg->WriteString("", "AVBARMatrix");
    reg->CloseKey();
    reg->OpenKey("AVBARMatrix", true);
    reg->WriteString("", "AV BAR Matrix");
    reg->OpenKey("DefaultIcon", true);
    reg->WriteString("", Application->ExeName + ",0");
    reg->CloseKey();
    reg->OpenKey("AVBARMatrix\\Shell\\Open\\command", true);
    reg->WriteString("", Application->ExeName + " %1");
    reg->CloseKey();

    reg->OpenKey(".avl", true);
    reg->WriteString("", "AVBARStudList");
    reg->CloseKey();
    reg->OpenKey("AVBARStudList", true);
    reg->WriteString("", "AV BAR Students list");
    reg->OpenKey("DefaultIcon", true);
    reg->WriteString("", Application->ExeName + ",0");
    reg->CloseKey();
    reg->OpenKey("AVBARStudList\\Shell\\Open\\command", true);
    reg->WriteString("", Application->ExeName + " %1");
    reg->CloseKey();

    delete reg;
    Application->MessageBoxA("File types have been successfully registered!",
      "Register", MB_OK | MB_ICONINFORMATION);
  }
  catch (Exception &)
  {
    ShowError("An unrecognized error during registering!");
  }
}
Exemple #17
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;
}
//---------------------------------------------------------------------------
void __fastcall TXirconForm::ButtonMergeServersClick(TObject *Sender)
{
  if ( Memo1->Lines->Count == 0 )
  {
    ShowMessage("No keys to write... first import from mIRC.ini");
    return;
  }

  String StrIdx, TempStr;

  TStringList* pSlNew = new TStringList();
  TStringList* pSlOld = new TStringList();
  TRegistry * MyRegistry = new TRegistry();

  try
  {
    if ( !pSlNew || !pSlOld  )
    {
      ShowMessage("Unable to create string-list!");
      return;
    }

    // Purge duplicates from new mIRC Memo1 servers...
    if ( CheckBoxElimDups->Checked )
    {
      pSlNew->Sorted = true;
      pSlNew->Duplicates = dupIgnore;
      pSlOld->Sorted = true;
      pSlOld->Duplicates = dupIgnore;
    }
    else
    {
      pSlNew->Sorted = false;
      pSlNew->Duplicates = dupAccept;
      pSlOld->Sorted = false;
      pSlOld->Duplicates = dupAccept;
    }

    // Fill StringList from new servers in Memo1, possibly sorting
    // and purging duplicates.
    pSlNew->AddStrings(Memo1->Lines);

    // Read existing server-list
    bool bHaveExisting = ReadXircServers( pSlOld );

    if ( bHaveExisting )
    {
      if ( !EraseXircServers() )
      {
        ShowMessage("Unable to erase old server-list!");
        return;
      }
    }

    MyRegistry->RootKey = HKEY_CURRENT_USER;

    if ( !MyRegistry->OpenKey(RegKey, true) )
    {
      ShowMessage("Unable to create registry key!");
      return;
    }

    // Merge the old list into the new...
    pSlNew->AddStrings(pSlOld);

    int RegIndex = 1;
    int NewIndex = 0;
    String TempStr;

    // Start writing merged server-list, up to 999 max
    for ( ; NewIndex < pSlNew->Count && RegIndex < 1000; NewIndex++ )
    {
      try
      {
        StrIdx = String( RegIndex );

        if ( RegIndex < 100 )
          StrIdx.Insert( "0", 1 );

        if ( RegIndex < 10 )
          StrIdx.Insert( "0", 1 );

        TempStr = pSlNew->Strings[NewIndex];

        if ( TempStr.Length() )
          MyRegistry->WriteString( StrIdx, TempStr );

        RegIndex++;
      }
      catch(...)
      {
        ShowMessage("Registry-write error during list merge!\n" + TempStr);
        return;
      }
    }

    ShowMessage("Wrote " + String(RegIndex-1) + " total servers!" );
    if ( pSlNew->Count > 999 )
      ShowMessage("Warning, " + String(pSlNew->Count-999) + " server(s)\n"
          "were not written because list is full..." );
  }
  __finally
  {
    try {
      if ( pSlNew != NULL )
        delete pSlNew;
      if ( pSlOld != NULL )
        delete pSlOld;
    } catch(...) {
    }
    try {
      if ( MyRegistry != NULL ) MyRegistry->CloseKey();
    } catch(...) {
    }
    try {
      if ( MyRegistry != NULL )
        delete MyRegistry;
    } catch(...) {
    }
  }

  Memo1->SetFocus();
}
Exemple #19
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;
}
//===========================================================================
//===========================================================================
//===========================================================================
//===========================================================================
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;
  }
}
//---------------------------------------------------------------------------
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;
}