예제 #1
0
파일: Unit1.cpp 프로젝트: rogertl/cbuilder
//---------------------------------------------------------------------------
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;
  }
}
예제 #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;
}
예제 #3
0
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;
  }
}
예제 #4
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;
    }
}
예제 #5
0
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;
}
예제 #6
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();
}
예제 #7
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);
  }
}
예제 #8
0
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;
  }
}
예제 #9
0
파일: Unit1.cpp 프로젝트: rogertl/cbuilder
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;
  }



}
예제 #10
0
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;

}
예제 #11
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;
}//---------------------------------------------------------------------------
예제 #12
0
//---------------------------------------------------------------------------
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;
}
예제 #13
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();
}
예제 #14
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;
예제 #15
0
void __fastcall TfrmPluginMain::FormCloseQuery(TObject *Sender, bool &CanClose)
{

    TRegistry * reg;

    try {
        reg = new TRegistry();
        reg->OpenKey("software\\PMMSoft\\Winamp controller\\server settings", true);

        // should implement end point edits
        // reg->WriteString("EndPoint", "");

        reg->WriteString("Visible", Visible?"true":"false");
    }
    __finally {
        delete reg;
    }

}
예제 #16
0
//---------------------------------------------------------------------------
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;

}
예제 #17
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;

}
예제 #18
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!");
  }
}
예제 #19
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;
}
예제 #20
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;
}
예제 #21
0
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();
    }

}
예제 #22
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;
    }
}
예제 #23
0
//---------------------------------------------------------------------------
bool applychanges()
{
	FILE *fh;
    char filename[256];
	bool result;
	bool file_exists;
	TRegistry *myreg;

	result = false;
	file_exists = false;

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

    myreg->WriteString( "PRIVATE_TREE", ampcfgform->privatetree->Text );
    myreg->WriteString( "PUBLIC_TREE", ampcfgform->publictree->Text );
    myreg->WriteString( "SITES_TREE", ampcfgform->sitestree->Text );

    myreg->WriteString( "AMP_HOST", ampcfgform->hostname->Text );
	myreg->WriteString( "AMP_URL", ampcfgform->ampurl->Text );
    myreg->WriteString( "ADMIN_URL", ampcfgform->adminurl->Text );
    myreg->WriteString( "ROOT_URL", ampcfgform->rooturl->Text );
	myreg->WriteString( "CGI_URL", ampcfgform->cgiurl->Text );

    strcpy( filename, ampcfgform->privatetree->Text.c_str() );
    strcat( filename, "\\etc\\ampconfig.cfg" );

	if ( access( filename, 0 ) == 0 ) file_exists = true;

	fh = fopen( filename, "w" );
	if ( fh )
	{
		fprintf( fh, "HTTPD_GROUP = nogroup\n" );
		fprintf( fh, "HTTPD_USER = nobody\n" );
		fprintf( fh, "AMP_HOST = %s\n", strtr( ampcfgform->hostname->Text.c_str(), "\\", "/" ) );
		fprintf( fh, "AMP_URL = %s\n", strtr( ampcfgform->ampurl->Text.c_str(), "\\", "/" ) );
		fprintf( fh, "AMP_ROOTURL = %s\n", strtr( ampcfgform->rooturl->Text.c_str(), "\\", "/" ) );
		fprintf( fh, "ADMIN_URL = %s\n", strtr( ampcfgform->adminurl->Text.c_str(), "\\", "/" ) );
		fprintf( fh, "CGI_URL = %s\n", strtr( ampcfgform->cgiurl->Text.c_str(), "\\", "/" ) );
		fprintf( fh, "PUBLIC_TREE = %s/\n", strtr( ampcfgform->publictree->Text.c_str(), "\\", "/" ) );
		fprintf( fh, "PRIVATE_TREE = %s/\n", strtr( ampcfgform->privatetree->Text.c_str(), "\\", "/" ) );
		fprintf( fh, "SITES_TREE =  %s/\n", strtr( ampcfgform->sitestree->Text.c_str(), "\\", "/" ) );

		// :TODO: teg 010724: language
		// Language should be set only the first time,
		// using file_exists variable.

		fprintf( fh, "AMP_LANG = en\n" );
		fclose( fh );

		strcpy( filename, ampcfgform->privatetree->Text.c_str() );
		strcat( filename, "\\etc\\ampdbconfig.cfg" );

	    fh = fopen( filename, "a" );
    	if ( fh )
	    {
        	fclose( fh );
	    	result = true;
    	}

		strcpy( filename, strtr( ampcfgform->publictree->Text.c_str(), "\\", "/" ) );
		strcat( filename, "\\cfgpath.php" );
		makecfgpathfile( filename );

		strcpy( filename, strtr( ampcfgform->publictree->Text.c_str(), "\\", "/" ) );
		strcat( filename, "\\root\\cfgpath.php" );
		makecfgpathfile( filename );

		strcpy( filename, strtr( ampcfgform->publictree->Text.c_str(), "\\", "/" ) );
		strcat( filename, "\\admin\\cfgpath.php" );
		makecfgpathfile( filename );

	    strcpy( filename, strtr( ampcfgform->publictree->Text.c_str(), "\\", "/" ) );
        strcat( filename, "\\cgi\\cfgpath.php" );
		makecfgpathfile( filename );
    }

	strcpy( filename, ampcfgform->privatetree->Text.c_str() );
	strcat( filename, "\\etc\\ampconfigpath.php" );

	fh = fopen( filename, "w" );
	if ( fh )
	{
		fprintf( fh, "<?php define( \"AMP_CONFIG\", \"%s/etc/ampconfig.cfg\" );?>\n", strtr( ampcfgform->privatetree->Text.c_str(), "\\", "/" ) );
        fclose( fh );
	}

    return result;
}
예제 #24
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;   }
}
예제 #25
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;
}
예제 #26
0
//---------------------------------------------------------------------------
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;
}
예제 #27
0
//---------------------------------------------------------------------------
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();
}
예제 #28
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);
  }
}
예제 #29
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;
}
예제 #30
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;
}