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; } }
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; }
//--------------------------------------------------------------------------- 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 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); } }
//--------------------------------------------------------------------------- bool __fastcall TXirconForm::EraseXircServers( void ) // Delete XiRCON Server list { TRegistry * MyRegistry = new TRegistry(); try { MyRegistry->RootKey = HKEY_CURRENT_USER; try { MyRegistry->DeleteKey(RegKey); } catch(ERegistryException &E) { return false; } } __finally { if ( MyRegistry ) delete MyRegistry; } return true; }
//=========================================================================== 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; } }
//--------------------------------------------------------------------------- // 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::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; }
bool TRegistryStorage::Copy(TRegistryStorage * Storage) { TRegistry * Registry = Storage->FRegistry; bool Result = true; std::unique_ptr<TStrings> Names(new TStringList()); try__finally { rde::vector<uint8_t> Buffer(1024); Registry->GetValueNames(Names.get()); intptr_t Index = 0; while ((Index < Names->GetCount()) && Result) { UnicodeString Name = MungeStr(Names->GetString(Index), GetForceAnsi()); DWORD Size = static_cast<DWORD>(Buffer.size()); DWORD Type; int RegResult = 0; do { RegResult = ::RegQueryValueEx(Registry->GetCurrentKey(), Name.c_str(), nullptr, &Type, &Buffer[0], &Size); if (RegResult == ERROR_MORE_DATA) { Buffer.resize(Size); } } while (RegResult == ERROR_MORE_DATA); Result = (RegResult == ERROR_SUCCESS); if (Result) { RegResult = ::RegSetValueEx(FRegistry->GetCurrentKey(), Name.c_str(), 0, Type, &Buffer[0], Size); Result = (RegResult == ERROR_SUCCESS); } ++Index; } } __finally { /* delete Names; */ }; return Result; }
//--------------------------------------------------------------------------- void __fastcall TestCarte::Scan_Arduino() { TRegistry *registre = new TRegistry(); registre->RootKey = HKEY_LOCAL_MACHINE; if (registre->OpenKeyReadOnly("SYSTEM\\CurrentControlSet\\Services\\usbser\\Enum") && registre->ValueExists("0")) { EtatDetect = true; } else { EtatDetect = false; } delete registre; //valable seulement pour 1 carte Arduino, sinon incrémente... //HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\usbser\Enum -> 0 -> USB\VID_2341&PID_0042\6493633303735151D061 //HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM -> \Device\USBSER000 -> COMxx }
//--------------------------------------------------------------------------- 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; } }
//--------------------------------------------------------------------------- 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 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; } }
//--------------------------------------------------------------------------- void __fastcall TMainForm::actUnregisterExecute(TObject *Sender) { try { TRegistry *reg = new TRegistry; reg->RootKey = HKEY_CLASSES_ROOT; reg->DeleteKey(".avm"); reg->DeleteKey("AVBARMatrix"); reg->DeleteKey(".avl"); reg->DeleteKey("AVBARStudList"); delete reg; Application->MessageBoxA("File types have been successfully unregistered!", "Register", MB_OK | MB_ICONINFORMATION); } catch (Exception &) { ShowError("An unrecognized error during registering!"); } }
//--------------------------------------------------------------------------- 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; }
//--------------------------------------------------------------------------- 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; }
//-------------------------------------------------------------------------- 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; }
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; } }
//--------------------------------------------------------------------------- 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 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(); }
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(); } }
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::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; } }
//=========================================================================== 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; } }
//--------------------------------------------------------------------------- AnsiString CheckOffice() { AnsiString S=""; TRegistry *Registry = new TRegistry; Registry->RootKey = HKEY_LOCAL_MACHINE; if (Registry->KeyExists("SOFTWARE\\Microsoft\\Office\\9.0\\Word")) S="MSO"; if (Registry->KeyExists("SOFTWARE\\Microsoft\\Office\\10.0\\Word")) S="MSO"; if (Registry->KeyExists("SOFTWARE\\Microsoft\\Office\\11.0\\Word")) S="MSO"; if (Registry->KeyExists("SOFTWARE\\Microsoft\\Office\\12.0\\Word")) S="MSO"; if (Registry->KeyExists("SOFTWARE\\OpenOffice.org\\OpenOffice.org")) S="OO"; delete Registry; return S; }
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;
//--------------------------------------------------------------------------- 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; }
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 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!"); } }
//--------------------------------------------------------------------------- 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; }