Пример #1
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;
}
Пример #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;
  }
}
Пример #3
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;
  }
}
Пример #4
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();
}
Пример #5
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;
}
Пример #6
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;
    }

}
Пример #7
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!");
  }
}
Пример #8
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;
}
Пример #9
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;
}
Пример #10
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;
}
Пример #11
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();
}
Пример #12
0
//===========================================================================
//===========================================================================
//===========================================================================
//===========================================================================
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;
  }
}