| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682 | 
							- //---------------------------------------------------------------------------
 
- #include <vcl.h>
 
- #pragma hdrstop
 
- #include "WinConfiguration.h"
 
- #include "Common.h"
 
- #include "Exceptions.h"
 
- #include "Bookmarks.h"
 
- #include "Terminal.h"
 
- #include "TextsWin.h"
 
- #include "WinInterface.h"
 
- #include "GUITools.h"
 
- #include "Tools.h"
 
- #include "Setup.h"
 
- #include "Security.h"
 
- #include "TerminalManager.h"
 
- #include "Cryptography.h"
 
- #include <VCLCommon.h>
 
- #include <InitGUID.h>
 
- #include <DragExt.h>
 
- #include <Math.hpp>
 
- //---------------------------------------------------------------------------
 
- #pragma package(smart_init)
 
- //---------------------------------------------------------------------------
 
- TWinConfiguration * WinConfiguration = NULL;
 
- //---------------------------------------------------------------------------
 
- static UnicodeString NotepadName(L"notepad.exe");
 
- //---------------------------------------------------------------------------
 
- __fastcall TEditorData::TEditorData() :
 
-   FileMask(L"*.*"),
 
-   Editor(edInternal),
 
-   ExternalEditor(L""),
 
-   ExternalEditorText(false),
 
-   SDIExternalEditor(false),
 
-   DetectMDIExternalEditor(false)
 
- {
 
- }
 
- //---------------------------------------------------------------------------
 
- __fastcall TEditorData::TEditorData(const TEditorData & Source) :
 
-   FileMask(Source.FileMask),
 
-   Editor(Source.Editor),
 
-   ExternalEditor(Source.ExternalEditor),
 
-   ExternalEditorText(Source.ExternalEditorText),
 
-   SDIExternalEditor(Source.SDIExternalEditor),
 
-   DetectMDIExternalEditor(Source.DetectMDIExternalEditor)
 
- {
 
- }
 
- //---------------------------------------------------------------------------
 
- #define C(Property) (Property == rhd.Property)
 
- bool __fastcall TEditorData::operator==(const TEditorData & rhd) const
 
- {
 
-   return
 
-     C(FileMask) &&
 
-     C(Editor) &&
 
-     C(ExternalEditor) &&
 
-     C(ExternalEditorText) &&
 
-     C(SDIExternalEditor) &&
 
-     C(DetectMDIExternalEditor) &&
 
-     true;
 
- }
 
- #undef C
 
- //---------------------------------------------------------------------------
 
- bool __fastcall TEditorData::DecideExternalEditorText(UnicodeString ExternalEditor)
 
- {
 
-   bool Result = false;
 
-   // By default we use default transfer mode (binary),
 
-   // as all reasonable 3rd party editors support all EOL styles.
 
-   // A notable exception is Windows Notepad, so here's an exception for it.
 
-   ReformatFileNameCommand(ExternalEditor);
 
-   UnicodeString ProgramName = ExtractProgramName(ExternalEditor);
 
-   // We explicitly do not use TEditorPreferences::GetDefaultExternalEditor(),
 
-   // as we need to explicitly refer to the Notepad, even if the default external
 
-   // editor ever changes
 
-   UnicodeString NotepadProgramName = ExtractProgramName(NotepadName);
 
-   if (SameText(ProgramName, NotepadProgramName))
 
-   {
 
-     Result = true;
 
-   }
 
-   return Result;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TEditorData::DecideExternalEditorText()
 
- {
 
-   if (DecideExternalEditorText(ExternalEditor))
 
-   {
 
-     ExternalEditorText = true;
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- __fastcall TEditorPreferences::TEditorPreferences()
 
- {
 
- }
 
- //---------------------------------------------------------------------------
 
- __fastcall TEditorPreferences::TEditorPreferences(const TEditorData & Data) :
 
-   FData(Data)
 
- {
 
- }
 
- //---------------------------------------------------------------------------
 
- bool __fastcall TEditorPreferences::operator==(const TEditorPreferences & rhp) const
 
- {
 
-   return (FData == rhp.FData);
 
- }
 
- #undef C
 
- //---------------------------------------------------------------------------
 
- bool __fastcall TEditorPreferences::Matches(const UnicodeString FileName,
 
-   bool Local, const TFileMasks::TParams & Params) const
 
- {
 
-   return FData.FileMask.Matches(FileName, Local, false, &Params);
 
- }
 
- //---------------------------------------------------------------------------
 
- UnicodeString __fastcall TEditorPreferences::GetDefaultExternalEditor()
 
- {
 
-   return NotepadName;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TEditorPreferences::LegacyDefaults()
 
- {
 
-   FData.ExternalEditor = GetDefaultExternalEditor();
 
-   FData.DecideExternalEditorText();
 
- }
 
- //---------------------------------------------------------------------------
 
- UnicodeString __fastcall TEditorPreferences::ExtractExternalEditorName() const
 
- {
 
-   DebugAssert(FData.Editor == edExternal);
 
-   UnicodeString ExternalEditor = FData.ExternalEditor;
 
-   ReformatFileNameCommand(ExternalEditor);
 
-   // Trim is a workaround for unknown problem with "notepad  " (2 trailing spaces)
 
-   return ExtractProgramName(ExternalEditor).Trim();
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TEditorPreferences::Load(THierarchicalStorage * Storage, bool Legacy)
 
- {
 
-   if (!Legacy)
 
-   {
 
-     FData.FileMask = Storage->ReadString(L"FileMask", FData.FileMask.Masks);
 
-   }
 
-   FData.Editor = (TEditor)Storage->ReadInteger(L"Editor", FData.Editor);
 
-   FData.ExternalEditor = Storage->ReadString(L"ExternalEditor", FData.ExternalEditor);
 
-   FData.ExternalEditorText = Storage->ReadBool(L"ExternalEditorText", FData.ExternalEditorText);
 
-   FData.SDIExternalEditor = Storage->ReadBool(L"SDIExternalEditor", FData.SDIExternalEditor);
 
-   FData.DetectMDIExternalEditor = Storage->ReadBool(L"DetectMDIExternalEditor", FData.DetectMDIExternalEditor);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TEditorPreferences::Save(THierarchicalStorage * Storage) const
 
- {
 
-   Storage->WriteString(L"FileMask", FData.FileMask.Masks);
 
-   Storage->WriteInteger(L"Editor", FData.Editor);
 
-   Storage->WriteString(L"ExternalEditor", FData.ExternalEditor);
 
-   Storage->WriteBool(L"ExternalEditorText", FData.ExternalEditorText);
 
-   Storage->WriteBool(L"SDIExternalEditor", FData.SDIExternalEditor);
 
-   Storage->WriteBool(L"DetectMDIExternalEditor", FData.DetectMDIExternalEditor);
 
- }
 
- //---------------------------------------------------------------------------
 
- TEditorData * __fastcall TEditorPreferences::GetData()
 
- {
 
-   // returning non-const data, possible data change, invalidate cached name
 
-   FName = L"";
 
-   return &FData;
 
- };
 
- //---------------------------------------------------------------------------
 
- UnicodeString __fastcall TEditorPreferences::GetName() const
 
- {
 
-   if (FName.IsEmpty())
 
-   {
 
-     if (FData.Editor == edInternal)
 
-     {
 
-       // StripHotkey is relic from times when INTERNAL_EDITOR_NAME was used
 
-       // also for the menu item caption
 
-       FName = StripHotkey(LoadStr(INTERNAL_EDITOR_NAME));
 
-     }
 
-     else if (FData.Editor == edOpen)
 
-     {
 
-       FName = StripHotkey(LoadStr(OPEN_EDITOR_NAME));
 
-     }
 
-     else
 
-     {
 
-       UnicodeString Program, Params, Dir;
 
-       UnicodeString ExternalEditor = FData.ExternalEditor;
 
-       ReformatFileNameCommand(ExternalEditor);
 
-       SplitCommand(ExternalEditor, Program, Params, Dir);
 
-       FName = ExtractFileName(Program);
 
-       int P = FName.LastDelimiter(L".");
 
-       if (P > 0)
 
-       {
 
-         FName.SetLength(P - 1);
 
-       }
 
-       if (FName.ByteType(1) == mbSingleByte)
 
-       {
 
-         if (FName.UpperCase() == FName)
 
-         {
 
-           FName = FName.LowerCase();
 
-         }
 
-         if (FName.LowerCase() == FName)
 
-         {
 
-           FName = FName.SubString(1, 1).UpperCase() +
 
-             FName.SubString(2, FName.Length() - 1);
 
-         }
 
-       }
 
-     }
 
-   }
 
-   return FName;
 
- }
 
- //---------------------------------------------------------------------------
 
- //---------------------------------------------------------------------------
 
- __fastcall TEditorList::TEditorList()
 
- {
 
-   Init();
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TEditorList::Init()
 
- {
 
-   FEditors = new TList();
 
-   FModified = false;
 
- }
 
- //---------------------------------------------------------------------------
 
- __fastcall TEditorList::~TEditorList()
 
- {
 
-   Clear();
 
-   delete FEditors;
 
- }
 
- //---------------------------------------------------------------------
 
- void __fastcall TEditorList::Modify()
 
- {
 
-   FModified = true;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TEditorList::Saved()
 
- {
 
-   FModified = false;
 
- }
 
- //---------------------------------------------------------------------------
 
- TEditorList & __fastcall TEditorList::operator=(const TEditorList & rhl)
 
- {
 
-   Clear();
 
-   for (int Index = 0; Index < rhl.Count; Index++)
 
-   {
 
-     Add(new TEditorPreferences(*rhl.Editors[Index]));
 
-   }
 
-   // there should be comparison of with the assigned list, but we rely on caller
 
-   // to do it instead (TWinConfiguration::SetEditorList)
 
-   Modify();
 
-   return *this;
 
- }
 
- //---------------------------------------------------------------------------
 
- bool __fastcall TEditorList::operator==(const TEditorList & rhl) const
 
- {
 
-   bool Result = (Count == rhl.Count);
 
-   if (Result)
 
-   {
 
-     int i = 0;
 
-     while ((i < Count) && Result)
 
-     {
 
-       Result = (*Editors[i]) == (*rhl.Editors[i]);
 
-       i++;
 
-     }
 
-   }
 
-   return Result;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TEditorList::Clear()
 
- {
 
-   for (int i = 0; i < Count; i++)
 
-   {
 
-     delete Editors[i];
 
-   }
 
-   FEditors->Clear();
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TEditorList::Add(TEditorPreferences * Editor)
 
- {
 
-   Insert(Count, Editor);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TEditorList::Insert(int Index, TEditorPreferences * Editor)
 
- {
 
-   FEditors->Insert(Index, reinterpret_cast<TObject *>(Editor));
 
-   Modify();
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TEditorList::Change(int Index, TEditorPreferences * Editor)
 
- {
 
-   if (!((*Editors[Index]) == *Editor))
 
-   {
 
-     delete Editors[Index];
 
-     FEditors->Items[Index] = (reinterpret_cast<TObject *>(Editor));
 
-     Modify();
 
-   }
 
-   else
 
-   {
 
-     delete Editor;
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TEditorList::Move(int CurIndex, int NewIndex)
 
- {
 
-   if (CurIndex != NewIndex)
 
-   {
 
-     FEditors->Move(CurIndex, NewIndex);
 
-     Modify();
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TEditorList::Delete(int Index)
 
- {
 
-   DebugAssert((Index >= 0) && (Index < Count));
 
-   delete Editors[Index];
 
-   FEditors->Delete(Index);
 
-   Modify();
 
- }
 
- //---------------------------------------------------------------------------
 
- const TEditorPreferences * __fastcall TEditorList::Find(
 
-   const UnicodeString FileName, bool Local, const TFileMasks::TParams & Params) const
 
- {
 
-   const TEditorPreferences * Result = NULL;
 
-   int i = 0;
 
-   while ((i < FEditors->Count) && (Result == NULL))
 
-   {
 
-     Result = Editors[i];
 
-     if (!Result->Matches(FileName, Local, Params))
 
-     {
 
-       Result = NULL;
 
-     }
 
-     i++;
 
-   }
 
-   return Result;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TEditorList::Load(THierarchicalStorage * Storage)
 
- {
 
-   int Index = 0;
 
-   bool Next;
 
-   do
 
-   {
 
-     UnicodeString Name = IntToStr(Index);
 
-     TEditorPreferences * Editor = NULL;
 
-     try
 
-     {
 
-       Next = Storage->OpenSubKey(Name, false);
 
-       if (Next)
 
-       {
 
-         try
 
-         {
 
-           Editor = new TEditorPreferences();
 
-           Editor->Load(Storage, false);
 
-         }
 
-         __finally
 
-         {
 
-           Storage->CloseSubKey();
 
-         }
 
-       }
 
-     }
 
-     catch(...)
 
-     {
 
-       delete Editor;
 
-       throw;
 
-     }
 
-     if (Editor != NULL)
 
-     {
 
-       FEditors->Add(reinterpret_cast<TObject *>(Editor));
 
-     }
 
-     Index++;
 
-   }
 
-   while (Next);
 
-   FModified = false;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TEditorList::Save(THierarchicalStorage * Storage) const
 
- {
 
-   Storage->ClearSubKeys();
 
-   for (int Index = 0; Index < Count; Index++)
 
-   {
 
-     if (Storage->OpenSubKey(IntToStr(Index), true))
 
-     {
 
-       try
 
-       {
 
-         Editors[Index]->Save(Storage);
 
-       }
 
-       __finally
 
-       {
 
-         Storage->CloseSubKey();
 
-       }
 
-     }
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- int __fastcall TEditorList::GetCount() const
 
- {
 
-   int X = FEditors->Count;
 
-   return X;
 
- }
 
- //---------------------------------------------------------------------------
 
- const TEditorPreferences * __fastcall TEditorList::GetEditor(int Index) const
 
- {
 
-   return reinterpret_cast<TEditorPreferences *>(FEditors->Items[Index]);
 
- }
 
- //---------------------------------------------------------------------------
 
- bool __fastcall TEditorList::IsDefaultList() const
 
- {
 
-   bool Result = true;
 
-   for (int Index = 0; Result && (Index < Count); Index++)
 
-   {
 
-     const TEditorPreferences * Editor = GetEditor(Index);
 
-     if (Editor->Data->Editor == edInternal)
 
-     {
 
-       // noop (keeps Result true)
 
-     }
 
-     else if (Editor->Data->Editor == edExternal)
 
-     {
 
-       UnicodeString ExternalEditor = Editor->ExtractExternalEditorName();
 
-       UnicodeString DefaultExternalEditor = ExtractProgramName(TEditorPreferences::GetDefaultExternalEditor());
 
-       Result = SameText(ExternalEditor, DefaultExternalEditor);
 
-     }
 
-     else
 
-     {
 
-       Result = false;
 
-     }
 
-   }
 
-   return Result;
 
- }
 
- //---------------------------------------------------------------------------
 
- //---------------------------------------------------------------------------
 
- __fastcall TWinConfiguration::TWinConfiguration(): TCustomWinConfiguration()
 
- {
 
-   FInvalidDefaultTranslationMessage = L"";
 
-   FDDExtInstalled = -1;
 
-   FBookmarks = new TBookmarks();
 
-   FCustomCommandList = new TCustomCommandList();
 
-   FEditorList = new TEditorList();
 
-   FDefaultUpdatesPeriod = 0;
 
-   FDontDecryptPasswords = 0;
 
-   FMasterPasswordSession = 0;
 
-   FMasterPasswordSessionAsked = false;
 
-   FSystemIconFont.reset(new TFont());
 
-   UpdateSystemIconFont();
 
-   Default();
 
-   try
 
-   {
 
-     CheckTranslationVersion(
 
-       GetResourceModuleName(Application->Name, ModuleFileName().c_str()), true);
 
-   }
 
-   catch(Exception & E)
 
-   {
 
-     FInvalidDefaultTranslationMessage = E.Message;
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- __fastcall TWinConfiguration::~TWinConfiguration()
 
- {
 
-   if (!FTemporarySessionFile.IsEmpty()) DeleteFile(ApiPath(FTemporarySessionFile));
 
-   ClearTemporaryLoginData();
 
-   delete FBookmarks;
 
-   delete FCustomCommandList;
 
-   delete FEditorList;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::Default()
 
- {
 
-   FCustomCommandsDefaults = true;
 
-   TCustomWinConfiguration::Default();
 
-   int WorkAreaWidthScaled = DimensionToDefaultPixelsPerInch(Screen->WorkAreaWidth);
 
-   int WorkAreaHeightScaled = DimensionToDefaultPixelsPerInch(Screen->WorkAreaHeight);
 
-   UnicodeString PixelsPerInchToolbarValue = "PixelsPerInch=" + SaveDefaultPixelsPerInch();
 
-   FDDAllowMove = false;
 
-   FDDAllowMoveInit = false;
 
-   FDDTransferConfirmation = asAuto;
 
-   FDDTemporaryDirectory = L"";
 
-   FDDWarnLackOfTempSpace = true;
 
-   FDDWarnLackOfTempSpaceRatio = 1.1;
 
-   FDDExtEnabled = DDExtInstalled;
 
-   FDDExtTimeout = MSecsPerSec;
 
-   FDeleteToRecycleBin = true;
 
-   FSelectDirectories = false;
 
-   FSelectMask = L"*.*";
 
-   FShowHiddenFiles = false;
 
-   FFormatSizeBytes = fbKilobytes;
 
-   FShowInaccesibleDirectories = true;
 
-   FConfirmTransferring = true;
 
-   FConfirmDeleting = true;
 
-   FConfirmRecycling = true;
 
-   FConfirmClosingSession = true;
 
-   FDoubleClickAction = dcaEdit;
 
-   FCopyOnDoubleClickConfirmation = false;
 
-   FDimmHiddenFiles = true;
 
-   FRenameWholeName = false;
 
-   FAutoStartSession = L"";
 
-   FExpertMode = true;
 
-   FUseLocationProfiles = false;
 
-   FUseSharedBookmarks = false;
 
-   FDefaultDirIsHome = true;
 
-   FDDDeleteDelay = 120;
 
-   FTemporaryDirectoryAppendSession = false;
 
-   FTemporaryDirectoryDeterministic = false;
 
-   FTemporaryDirectoryAppendPath = true;
 
-   FTemporaryDirectoryCleanup = true;
 
-   FConfirmTemporaryDirectoryCleanup = true;
 
-   FPreservePanelState = true;
 
-   FLastStoredSession = L"";
 
-   // deliberately not being saved, so that when saving ad-hoc workspace,
 
-   // we do not offer to overwrite the last saved workspace, what may be undesirable
 
-   FLastWorkspace = L"";
 
-   FAutoSaveWorkspace = false;
 
-   FAutoSaveWorkspacePasswords = false;
 
-   FAutoWorkspace = L"";
 
-   FPathInCaption = picShort;
 
-   FMinimizeToTray = false;
 
-   FMinimizeToTrayOnce = false;
 
-   FBalloonNotifications = true;
 
-   FNotificationsTimeout = 10;
 
-   FNotificationsStickTime = 2;
 
-   FCopyParamAutoSelectNotice = true;
 
-   FLockToolbars = false;
 
-   FSelectiveToolbarText = true;
 
-   FAutoOpenInPutty = false;
 
-   FRefreshRemotePanel = false;
 
-   FRefreshRemotePanelInterval = TDateTime(0, 1, 0, 0);
 
-   FPanelFont.FontName = L"";
 
-   FPanelFont.FontSize = 0;
 
-   FPanelFont.FontStyle = 0;
 
-   FPanelFont.FontCharset = DEFAULT_CHARSET;
 
-   FFullRowSelect = false;
 
-   FOfferedEditorAutoConfig = false;
 
-   FVersionHistory = L"";
 
-   AddVersionToHistory();
 
-   FUseMasterPassword = false;
 
-   FPlainMasterPasswordEncrypt = L"";
 
-   FPlainMasterPasswordDecrypt = L"";
 
-   FMasterPasswordVerifier = L"";
 
-   FOpenedStoredSessionFolders = L"";
 
-   FAutoImportedFromPuttyOrFilezilla = false;
 
-   FGenerateUrlComponents = -1;
 
-   FGenerateUrlCodeTarget = guctUrl;
 
-   FGenerateUrlScriptFormat = sfScriptFile;
 
-   FGenerateUrlAssemblyLanguage = alCSharp;
 
-   FExternalSessionInExistingInstance = true;
 
-   FKeepOpenWhenNoSession = false;
 
-   FLocalIconsByExt = false;
 
-   FBidiModeOverride = lfoLanguageIfRecommended;
 
-   FFlipChildrenOverride = lfoLanguageIfRecommended;
 
-   FShowTips = true;
 
-   FTipsSeen = L"";
 
-   FTipsShown = Now();
 
-   FRunsSinceLastTip = 0;
 
-   HonorDrivePolicy = true;
 
-   FEditor.Font.FontName = DefaultFixedWidthFontName;
 
-   FEditor.Font.FontSize = DefaultFixedWidthFontSize;
 
-   FEditor.Font.FontStyle = 0;
 
-   FEditor.Font.FontCharset = DEFAULT_CHARSET;
 
-   FEditor.FontColor = TColor(0);
 
-   FEditor.BackgroundColor = TColor(0);
 
-   FEditor.WordWrap = false;
 
-   FEditor.FindText = L"";
 
-   FEditor.ReplaceText = L"";
 
-   FEditor.FindMatchCase = false;
 
-   FEditor.FindWholeWord = false;
 
-   FEditor.FindDown = true;
 
-   FEditor.TabSize = 8;
 
-   FEditor.MaxEditors = 500;
 
-   FEditor.EarlyClose = 2; // seconds
 
-   FEditor.SDIShellEditor = false;
 
-   FEditor.WindowParams = L"";
 
-   FEditor.Encoding = CP_ACP;
 
-   FEditor.WarnOnEncodingFallback = true;
 
-   FEditor.WarnOrLargeFileSize = true;
 
-   FQueueView.Height = 140;
 
-   FQueueView.HeightPixelsPerInch = USER_DEFAULT_SCREEN_DPI;
 
-   // with 1000 pixels wide screen, both interfaces are wide enough to fit wider queue
 
-   FQueueView.Layout =
 
-     UnicodeString((WorkAreaWidthScaled > 1000) ? L"70,250,250,80,80,80,100" : L"70,160,160,80,80,80,100") +
 
-     // WORKAROUND (the comma), see GetListViewStr
 
-     L",;" + SaveDefaultPixelsPerInch();
 
-   FQueueView.Show = qvHideWhenEmpty;
 
-   FQueueView.LastHideShow = qvHideWhenEmpty;
 
-   FQueueView.ToolBar = true;
 
-   FQueueView.Label = true;
 
-   FEnableQueueByDefault = true;
 
-   FUpdates.Period = FDefaultUpdatesPeriod;
 
-   FUpdates.LastCheck = 0;
 
-   FUpdates.HaveResults = false;
 
-   FUpdates.ShownResults = false;
 
-   FUpdates.BetaVersions = asAuto;
 
-   FUpdates.ShowOnStartup = true;
 
-   FUpdates.AuthenticationEmail = L"";
 
-   // for backward compatibility the default is decided based on value of ProxyHost
 
-   FUpdates.ConnectionType = (TConnectionType)-1;
 
-   FUpdates.ProxyHost = L""; // keep empty (see above)
 
-   FUpdates.ProxyPort = 8080;
 
-   FUpdates.Results.Reset();
 
-   FUpdates.DotNetVersion = L"";
 
-   FUpdates.ConsoleVersion = L"";
 
-   FLogWindowOnStartup = true;
 
-   FLogWindowParams = FormatDefaultWindowParams(500, 400);
 
-   int ExplorerWidth = Min(WorkAreaWidthScaled - 40, 960);
 
-   int ExplorerHeight = Min(WorkAreaHeightScaled - 30, 720);
 
-   FScpExplorer.WindowParams = FormatDefaultWindowParams(ExplorerWidth, ExplorerHeight);
 
-   // WORKAROUND (the semicolon, see TCustomListViewColProperties.GetParamsStr, and see other instances below)
 
-   FScpExplorer.DirViewParams = L"0;1;0|150,1;70,1;150,1;79,1;62,1;55,0;20,0;150,0;125,0;@" + SaveDefaultPixelsPerInch() + L"|6;7;8;0;1;2;3;4;5";
 
-   FScpExplorer.ToolbarsLayout =
 
-     UnicodeString(
 
-       L"Queue_Visible=1,Queue_LastDock=QueueDock,Queue_DockRow=0,Queue_DockPos=-1,Queue_FloatLeft=0,Queue_FloatTop=0,Queue_FloatRightX=0,"
 
-        "Menu_Visible=1,Menu_DockedTo=TopDock,Menu_LastDock=TopDock,Menu_DockRow=0,Menu_DockPos=0,Menu_FloatLeft=0,Menu_FloatTop=0,Menu_FloatRightX=0,"
 
-        "Buttons_Visible=1,Buttons_DockedTo=TopDock,Buttons_LastDock=TopDock,Buttons_DockRow=2,Buttons_DockPos=0,Buttons_FloatLeft=0,Buttons_FloatTop=0,Buttons_FloatRightX=0,"
 
-        "Selection_Visible=0,Selection_DockedTo=TopDock,Selection_LastDock=TopDock,Selection_DockRow=3,Selection_DockPos=0,Selection_FloatLeft=227,Selection_FloatTop=445,Selection_FloatRightX=0,"
 
-        "Session_Visible=0,Session_DockedTo=TopDock,Session_LastDock=TopDock,Session_DockRow=6,Session_DockPos=0,Session_FloatLeft=39,Session_FloatTop=160,Session_FloatRightX=0,"
 
-        "Preferences_Visible=1,Preferences_DockedTo=TopDock,Preferences_LastDock=TopDock,Preferences_DockRow=4,Preferences_DockPos=0,Preferences_FloatLeft=0,Preferences_FloatTop=0,Preferences_FloatRightX=0,"
 
-        "Sort_Visible=0,Sort_DockedTo=TopDock,Sort_LastDock=TopDock,Sort_DockRow=5,Sort_DockPos=0,Sort_FloatLeft=0,Sort_FloatTop=0,Sort_FloatRightX=0,"
 
-        "Address_Visible=1,Address_DockedTo=TopDock,Address_LastDock=TopDock,Address_DockRow=1,Address_DockPos=0,Address_FloatLeft=0,Address_FloatTop=0,Address_FloatRightX=0,"
 
-        "Updates_Visible=1,Updates_DockedTo=TopDock,Updates_LastDock=TopDock,Updates_DockRow=4,Updates_DockPos=416,Updates_FloatLeft=0,Updates_FloatTop=0,Updates_FloatRightX=0,"
 
-        "Transfer_Visible=1,Transfer_DockedTo=TopDock,Transfer_LastDock=TopDock,Transfer_DockRow=4,Transfer_DockPos=194,Transfer_FloatLeft=0,Transfer_FloatTop=0,Transfer_FloatRightX=0,"
 
-        "CustomCommands_Visible=0,CustomCommands_DockedTo=TopDock,CustomCommands_LastDock=TopDock,CustomCommands_DockRow=7,CustomCommands_DockPos=0,CustomCommands_FloatLeft=0,CustomCommands_FloatTop=0,CustomCommands_FloatRightX=0,") +
 
-     PixelsPerInchToolbarValue;
 
-   FScpExplorer.SessionsTabs = true;
 
-   FScpExplorer.StatusBar = true;
 
-   FScpExplorer.LastLocalTargetDirectory = GetPersonalFolder();
 
-   FScpExplorer.ViewStyle = 0; /* vsIcon */
 
-   FScpExplorer.ShowFullAddress = true;
 
-   FScpExplorer.DriveView = true;
 
-   FScpExplorer.DriveViewWidth = 180;
 
-   FScpExplorer.DriveViewWidthPixelsPerInch = USER_DEFAULT_SCREEN_DPI;
 
-   int CommanderWidth = Min(WorkAreaWidthScaled - 40, 1090);
 
-   int CommanderHeight = Min(WorkAreaHeightScaled - 30, 700);
 
-   FScpCommander.WindowParams = FormatDefaultWindowParams(CommanderWidth, CommanderHeight);
 
-   FScpCommander.LocalPanelWidth = 0.5;
 
-   FScpCommander.SwappedPanels = false;
 
-   FScpCommander.SessionsTabs = true;
 
-   FScpCommander.StatusBar = true;
 
-   FScpCommander.NortonLikeMode = nlKeyboard;
 
-   FScpCommander.PreserveLocalDirectory = false;
 
-   // Toolbar2_FloatRightX=1 makes keybar apper initially "in column" when undocked
 
-   FScpCommander.ToolbarsLayout =
 
-     UnicodeString(
 
-       L"Queue_Visible=1,Queue_LastDock=QueueDock,Queue_DockRow=0,Queue_DockPos=-1,Queue_FloatLeft=0,Queue_FloatTop=0,Queue_FloatRightX=0,"
 
-        "Menu_Visible=1,Menu_DockedTo=TopDock,Menu_LastDock=TopDock,Menu_DockRow=0,Menu_DockPos=0,Menu_FloatLeft=0,Menu_FloatTop=0,Menu_FloatRightX=0,"
 
-        "Preferences_Visible=1,Preferences_DockedTo=TopDock,Preferences_LastDock=TopDock,Preferences_DockRow=1,Preferences_DockPos=228,Preferences_FloatLeft=0,Preferences_FloatTop=0,Preferences_FloatRightX=0,"
 
-        "Session_Visible=0,Session_DockedTo=TopDock,Session_LastDock=TopDock,Session_DockRow=1,Session_DockPos=602,Session_FloatLeft=380,Session_FloatTop=197,Session_FloatRightX=0,"
 
-        "Sort_Visible=0,Sort_DockedTo=TopDock,Sort_LastDock=TopDock,Sort_DockRow=2,Sort_DockPos=0,Sort_FloatLeft=0,Sort_FloatTop=0,Sort_FloatRightX=0,"
 
-        "Commands_Visible=1,Commands_DockedTo=TopDock,Commands_LastDock=TopDock,Commands_DockRow=1,Commands_DockPos=0,Commands_FloatLeft=0,Commands_FloatTop=0,Commands_FloatRightX=0,"
 
-        "Updates_Visible=1,Updates_DockedTo=TopDock,Updates_LastDock=TopDock,Updates_DockRow=1,Updates_DockPos=619,Updates_FloatLeft=0,Updates_FloatTop=0,Updates_FloatRightX=0,"
 
-        "Transfer_Visible=1,Transfer_DockedTo=TopDock,Transfer_LastDock=TopDock,Transfer_DockRow=1,Transfer_DockPos=364,Transfer_FloatLeft=0,Transfer_FloatTop=0,Transfer_FloatRightX=0,"
 
-        "CustomCommands_Visible=0,CustomCommands_DockedTo=TopDock,CustomCommands_LastDock=TopDock,CustomCommands_DockRow=3,CustomCommands_DockPos=0,CustomCommands_FloatLeft=0,CustomCommands_FloatTop=0,CustomCommands_FloatRightX=0,"
 
-        "RemoteHistory_Visible=1,RemoteHistory_DockedTo=RemoteTopDock,RemoteHistory_LastDock=RemoteTopDock,RemoteHistory_DockRow=0,RemoteHistory_DockPos=172,RemoteHistory_FloatLeft=0,RemoteHistory_FloatTop=0,RemoteHistory_FloatRightX=0,"
 
-        "RemoteNavigation_Visible=1,RemoteNavigation_DockedTo=RemoteTopDock,RemoteNavigation_LastDock=RemoteTopDock,RemoteNavigation_DockRow=0,RemoteNavigation_DockPos=252,RemoteNavigation_FloatLeft=0,RemoteNavigation_FloatTop=0,RemoteNavigation_FloatRightX=0,"
 
-        "RemotePath_Visible=1,RemotePath_DockedTo=RemoteTopDock,RemotePath_LastDock=RemoteTopDock,RemotePath_DockRow=0,RemotePath_DockPos=0,RemotePath_FloatLeft=0,RemotePath_FloatTop=0,RemotePath_FloatRightX=0,"
 
-        "RemoteFile_Visible=1,RemoteFile_DockedTo=RemoteTopDock,RemoteFile_LastDock=RemoteTopDock,RemoteFile_DockRow=1,RemoteFile_DockPos=0,RemoteFile_FloatLeft=0,RemoteFile_FloatTop=0,RemoteFile_FloatRightX=0,"
 
-        "RemoteSelection_Visible=1,RemoteSelection_DockedTo=RemoteTopDock,RemoteSelection_LastDock=RemoteTopDock,RemoteSelection_DockRow=1,RemoteSelection_DockPos=345,RemoteSelection_FloatLeft=0,RemoteSelection_FloatTop=0,RemoteSelection_FloatRightX=0,"
 
-        "LocalHistory_Visible=1,LocalHistory_DockedTo=LocalTopDock,LocalHistory_LastDock=LocalTopDock,LocalHistory_DockRow=0,LocalHistory_DockPos=207,LocalHistory_FloatLeft=0,LocalHistory_FloatTop=0,LocalHistory_FloatRightX=0,"
 
-        "LocalNavigation_Visible=1,LocalNavigation_DockedTo=LocalTopDock,LocalNavigation_LastDock=LocalTopDock,LocalNavigation_DockRow=0,LocalNavigation_DockPos=287,LocalNavigation_FloatLeft=0,LocalNavigation_FloatTop=0,LocalNavigation_FloatRightX=0,"
 
-        "LocalPath_Visible=1,LocalPath_DockedTo=LocalTopDock,LocalPath_LastDock=LocalTopDock,LocalPath_DockRow=0,LocalPath_DockPos=0,LocalPath_FloatLeft=0,LocalPath_FloatTop=0,LocalPath_FloatRightX=0,"
 
-        "LocalFile_Visible=1,LocalFile_DockedTo=LocalTopDock,LocalFile_LastDock=LocalTopDock,LocalFile_DockRow=1,LocalFile_DockPos=0,LocalFile_FloatLeft=0,LocalFile_FloatTop=0,LocalFile_FloatRightX=0,"
 
-        "LocalSelection_Visible=1,LocalSelection_DockedTo=LocalTopDock,LocalSelection_LastDock=LocalTopDock,LocalSelection_DockRow=1,LocalSelection_DockPos=329,LocalSelection_FloatLeft=0,LocalSelection_FloatTop=0,LocalSelection_FloatRightX=0,"
 
-        "Toolbar2_Visible=0,Toolbar2_DockedTo=BottomDock,Toolbar2_LastDock=BottomDock,Toolbar2_DockRow=1,Toolbar2_DockPos=0,Toolbar2_FloatLeft=0,Toolbar2_FloatTop=0,Toolbar2_FloatRightX=1,"
 
-        "CommandLine_Visible=0,CommandLine_DockedTo=BottomDock,CommandLine_LastDock=BottomDock,CommandLine_DockRow=0,CommandLine_DockPos=0,CommandLine_FloatLeft=0,CommandLine_FloatTop=0,CommandLine_FloatRightX=0,") +
 
-     PixelsPerInchToolbarValue;
 
-   FScpCommander.CurrentPanel = osLocal;
 
-   FScpCommander.CompareByTime = true;
 
-   FScpCommander.CompareBySize = false;
 
-   FScpCommander.TreeOnLeft = false;
 
-   FScpCommander.ExplorerKeyboardShortcuts = false;
 
-   FScpCommander.SystemContextMenu = false;
 
-   FScpCommander.RemotePanel.DirViewParams = L"0;1;0|150,1;70,1;150,1;79,1;62,1;55,0;20,0;150,0;125,0;@" + SaveDefaultPixelsPerInch() + L"|6;7;8;0;1;2;3;4;5";
 
-   FScpCommander.RemotePanel.StatusBar = true;
 
-   FScpCommander.RemotePanel.DriveView = false;
 
-   FScpCommander.RemotePanel.DriveViewHeight = 100;
 
-   FScpCommander.RemotePanel.DriveViewHeightPixelsPerInch = USER_DEFAULT_SCREEN_DPI;
 
-   FScpCommander.RemotePanel.DriveViewWidth = 100;
 
-   FScpCommander.RemotePanel.DriveViewWidthPixelsPerInch = USER_DEFAULT_SCREEN_DPI;
 
-   FScpCommander.LocalPanel.DirViewParams = L"0;1;0|150,1;70,1;120,1;150,1;55,0;55,0;@" + SaveDefaultPixelsPerInch() + L"|5;0;1;2;3;4";
 
-   FScpCommander.LocalPanel.StatusBar = true;
 
-   FScpCommander.LocalPanel.DriveView = false;
 
-   FScpCommander.LocalPanel.DriveViewHeight = 100;
 
-   FScpCommander.LocalPanel.DriveViewHeightPixelsPerInch = USER_DEFAULT_SCREEN_DPI;
 
-   FScpCommander.LocalPanel.DriveViewWidth = 100;
 
-   FScpCommander.LocalPanel.DriveViewWidthPixelsPerInch = USER_DEFAULT_SCREEN_DPI;
 
-   FBookmarks->Clear();
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::DefaultLocalized()
 
- {
 
-   TGUIConfiguration::DefaultLocalized();
 
-   if (FCustomCommandsDefaults)
 
-   {
 
-     FCustomCommandList->Clear();
 
-     FCustomCommandList->Add(LoadStr(CUSTOM_COMMAND_EXECUTE), L"\"./!\"", 0);
 
-     FCustomCommandList->Add(LoadStr(CUSTOM_COMMAND_TOUCH), L"touch \"!\"", ccApplyToDirectories | ccRecursive);
 
-     FCustomCommandList->Add(LoadStr(CUSTOM_COMMAND_TAR),
 
-       FORMAT(L"tar -cz  -f \"!?%s?archive.tgz!\" !&",
 
-         (LoadStr(CUSTOM_COMMAND_TAR_ARCHIVE))), ccApplyToDirectories);
 
-     FCustomCommandList->Add(LoadStr(CUSTOM_COMMAND_UNTAR),
 
-       FORMAT(L"tar -xz --directory=\"!?%s?.!\" -f \"!\"",
 
-         (LoadStr(CUSTOM_COMMAND_UNTAR_DIRECTORY))), 0);
 
-     FCustomCommandList->Add(LoadStr(CUSTOM_COMMAND_GREP),
 
-       FORMAT(L"grep \"!?%s?!\" !&", (LoadStr(CUSTOM_COMMAND_GREP_PATTERN))),
 
-       ccShowResults);
 
-     FCustomCommandList->Add(LoadStr(CUSTOM_COMMAND_FC),
 
-       L"cmd /c fc \"!\" \"\!^!\" | more && pause", ccLocal);
 
-     FCustomCommandList->Add(LoadStr(CUSTOM_COMMAND_PRINT), L"notepad.exe /p \"!\"", ccLocal);
 
-     FCustomCommandList->Reset();
 
-     FCustomCommandsDefaults = true;
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- bool __fastcall TWinConfiguration::DetectRegistryStorage(HKEY RootKey)
 
- {
 
-   bool Result = false;
 
-   TRegistryStorage * Storage = new TRegistryStorage(RegistryStorageKey, RootKey);
 
-   try
 
-   {
 
-     if (Storage->OpenRootKey(false))
 
-     {
 
-       Result = true;
 
-       Storage->CloseSubKey();
 
-     }
 
-   }
 
-   __finally
 
-   {
 
-     delete Storage;
 
-   }
 
-   return Result;
 
- }
 
- //---------------------------------------------------------------------------
 
- bool __fastcall TWinConfiguration::CanWriteToStorage()
 
- {
 
-   bool Result = false;
 
-   try
 
-   {
 
-     THierarchicalStorage * Storage = CreateConfigStorage();
 
-     try
 
-     {
 
-       Storage->AccessMode = smReadWrite;
 
-       // This is actually not very good test, as we end up potentially with
 
-       // the very same config, and TIniFileStorage file won't even try to
 
-       // write the file then. Lucliky, we use this for empty config only,
 
-       // so we end up with at least an empty section.
 
-       if (Storage->OpenSubKey(ConfigurationSubKey, true))
 
-       {
 
-         Storage->WriteBool(L"WriteTest", true);
 
-         Storage->DeleteValue(L"WriteTest");
 
-       }
 
-       Storage->Flush();
 
-     }
 
-     __finally
 
-     {
 
-       delete Storage;
 
-     }
 
-     Result = true;
 
-   }
 
-   catch(...)
 
-   {
 
-   }
 
-   return Result;
 
- }
 
- //---------------------------------------------------------------------------
 
- TStorage __fastcall TWinConfiguration::GetStorage()
 
- {
 
-   if (FStorage == stDetect)
 
-   {
 
-     if (FindResourceEx(NULL, RT_RCDATA, L"WINSCP_SESSION",
 
-       MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL)))
 
-     {
 
-       FTemporarySessionFile =
 
-         IncludeTrailingBackslash(SystemTemporaryDirectory()) + L"winscps.tmp";
 
-       DumpResourceToFile(L"WINSCP_SESSION", FTemporarySessionFile);
 
-       FEmbeddedSessions = true;
 
-       FTemporaryKeyFile =
 
-         IncludeTrailingBackslash(SystemTemporaryDirectory()) + L"winscpk.tmp";
 
-       if (!DumpResourceToFile(L"WINSCP_KEY", FTemporaryKeyFile))
 
-       {
 
-         FTemporaryKeyFile = L"";
 
-       }
 
-     }
 
-     FStorage = stIniFile;
 
-     if (!FileExists(ApiPath(IniFileStorageNameForReading)))
 
-     {
 
-       if (DetectRegistryStorage(HKEY_CURRENT_USER) ||
 
-           DetectRegistryStorage(HKEY_LOCAL_MACHINE) ||
 
-           // FStorage is now stIniFile, so this tests writing to an INI file.
 
-           // As we fall back to user profile folder, when application folder
 
-           // is not writtable, it is actually unlikely that the below test ever fails.
 
-           !CanWriteToStorage())
 
-       {
 
-         FStorage = stRegistry;
 
-       }
 
-     }
 
-   }
 
-   TStorage Result = TCustomWinConfiguration::GetStorage();
 
-   return Result;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::Saved()
 
- {
 
-   TCustomWinConfiguration::Saved();
 
-   FBookmarks->ModifyAll(false);
 
-   FCustomCommandList->Reset();
 
-   FEditorList->Saved();
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::RecryptPasswords(TStrings * RecryptPasswordErrors)
 
- {
 
-   TCustomWinConfiguration::RecryptPasswords(RecryptPasswordErrors);
 
-   try
 
-   {
 
-     TTerminalManager * Manager = TTerminalManager::Instance(false);
 
-     DebugAssert(Manager != NULL);
 
-     if (Manager != NULL)
 
-     {
 
-       Manager->RecryptPasswords();
 
-     }
 
-   }
 
-   catch (Exception & E)
 
-   {
 
-     UnicodeString Message;
 
-     if (ExceptionMessage(&E, Message))
 
-     {
 
-       // we do not expect this really to happen,
 
-       // so we do not bother providing context
 
-       RecryptPasswordErrors->Add(Message);
 
-     }
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- bool __fastcall TWinConfiguration::GetUseMasterPassword()
 
- {
 
-   return FUseMasterPassword;
 
- }
 
- //---------------------------------------------------------------------------
 
- THierarchicalStorage * TWinConfiguration::CreateScpStorage(bool & SessionList)
 
- {
 
-   // Detect embedded session, if not checked yet
 
-   GetStorage();
 
-   THierarchicalStorage * Result;
 
-   if (SessionList && !FTemporarySessionFile.IsEmpty())
 
-   {
 
-     Result = new TIniFileStorage(FTemporarySessionFile);
 
-     // This is session-list specific store, so the only instance,
 
-     // we do not reset the SessionList argument
 
-     // (compare TConfiguration::CreateScpStorage)
 
-   }
 
-   else
 
-   {
 
-     Result = TCustomWinConfiguration::CreateScpStorage(SessionList);
 
-   }
 
-   return Result;
 
- }
 
- //---------------------------------------------------------------------------
 
- // duplicated from core\configuration.cpp
 
- #define LASTELEM(ELEM) \
 
-   ELEM.SubString(ELEM.LastDelimiter(L".>")+1, ELEM.Length() - ELEM.LastDelimiter(L".>"))
 
- #define BLOCK(KEY, CANCREATE, BLOCK) \
 
-   if (Storage->OpenSubKey(KEY, CANCREATE, true)) try { BLOCK } __finally { Storage->CloseSubKey(); }
 
- #define KEY(TYPE, VAR) KEYEX(TYPE, VAR, PropertyToKey(TEXT(#VAR)))
 
- #define REGCONFIG(CANCREATE) \
 
-   BLOCK(L"Interface", CANCREATE, \
 
-     KEYEX(Integer,DoubleClickAction, L"CopyOnDoubleClick"); \
 
-     KEY(Bool,     CopyOnDoubleClickConfirmation); \
 
-     KEY(Bool,     DDAllowMove); \
 
-     KEY(Bool,     DDAllowMoveInit); \
 
-     KEYEX(Integer, DDTransferConfirmation, L"DDTransferConfirmation2"); \
 
-     KEY(String,   DDTemporaryDirectory); \
 
-     KEY(Bool,     DDWarnLackOfTempSpace); \
 
-     KEY(Float,    DDWarnLackOfTempSpaceRatio); \
 
-     KEY(Bool,     DeleteToRecycleBin); \
 
-     KEY(Bool,     DimmHiddenFiles); \
 
-     KEY(Bool,     RenameWholeName); \
 
-     KEY(Bool,     SelectDirectories); \
 
-     KEY(String,   SelectMask); \
 
-     KEY(Bool,     ShowHiddenFiles); \
 
-     KEY(Integer,  FormatSizeBytes); \
 
-     KEY(Bool,     ShowInaccesibleDirectories); \
 
-     KEY(Bool,     ConfirmTransferring); \
 
-     KEY(Bool,     ConfirmDeleting); \
 
-     KEY(Bool,     ConfirmRecycling); \
 
-     KEY(Bool,     ConfirmClosingSession); \
 
-     KEY(String,   AutoStartSession); \
 
-     KEY(Bool,     UseLocationProfiles); \
 
-     KEY(Bool,     UseSharedBookmarks); \
 
-     KEY(Integer,  LocaleSafe); \
 
-     KEY(Bool,     DDExtEnabled); \
 
-     KEY(Integer,  DDExtTimeout); \
 
-     KEY(Bool,     DefaultDirIsHome); \
 
-     KEY(Bool,     TemporaryDirectoryAppendSession); \
 
-     KEY(Bool,     TemporaryDirectoryAppendPath); \
 
-     KEY(Bool,     TemporaryDirectoryDeterministic); \
 
-     KEY(Bool,     TemporaryDirectoryCleanup); \
 
-     KEY(Bool,     ConfirmTemporaryDirectoryCleanup); \
 
-     KEY(Bool,     PreservePanelState); \
 
-     KEY(String,   LastStoredSession); \
 
-     KEY(Bool,     AutoSaveWorkspace); \
 
-     KEY(Bool,     AutoSaveWorkspacePasswords); \
 
-     KEY(String,   AutoWorkspace); \
 
-     KEY(Integer,  PathInCaption); \
 
-     KEY(Bool,     MinimizeToTray); \
 
-     KEY(Bool,     BalloonNotifications); \
 
-     KEY(Integer,  NotificationsTimeout); \
 
-     KEY(Integer,  NotificationsStickTime); \
 
-     KEY(Bool,     CopyParamAutoSelectNotice); \
 
-     KEY(Bool,     LockToolbars); \
 
-     KEY(Bool,     SelectiveToolbarText); \
 
-     KEY(Bool,     AutoOpenInPutty); \
 
-     KEY(Bool,     RefreshRemotePanel); \
 
-     KEY(DateTime, RefreshRemotePanelInterval); \
 
-     KEYEX(String, PanelFont.FontName, L"PanelFontName"); \
 
-     KEYEX(Integer,PanelFont.FontSize, L"PanelFontSize"); \
 
-     KEYEX(Integer,PanelFont.FontStyle, L"PanelFontStyle"); \
 
-     KEYEX(Integer,PanelFont.FontCharset, L"PanelFontCharset"); \
 
-     KEY(Bool,     FullRowSelect); \
 
-     KEY(Bool,     OfferedEditorAutoConfig); \
 
-     KEY(Integer,  LastMonitor); \
 
-     KEY(String,   VersionHistory); \
 
-     KEY(Bool,     EnableQueueByDefault); \
 
-     KEY(String,   OpenedStoredSessionFolders); \
 
-     KEY(Bool,     AutoImportedFromPuttyOrFilezilla); \
 
-     KEY(Integer,  GenerateUrlComponents); \
 
-     KEY(Integer,  GenerateUrlCodeTarget); \
 
-     KEY(Integer,  GenerateUrlScriptFormat); \
 
-     KEY(Integer,  GenerateUrlAssemblyLanguage); \
 
-     KEY(Bool,     ExternalSessionInExistingInstance); \
 
-     KEY(Bool,     KeepOpenWhenNoSession); \
 
-     KEY(Bool,     LocalIconsByExt); \
 
-     KEY(Integer,  BidiModeOverride); \
 
-     KEY(Integer,  FlipChildrenOverride); \
 
-     KEY(Bool,     ShowTips); \
 
-     KEY(String,   TipsSeen); \
 
-     KEY(DateTime, TipsShown); \
 
-     KEY(Integer,  RunsSinceLastTip); \
 
-     KEY(Bool,     HonorDrivePolicy); \
 
-   ); \
 
-   BLOCK(L"Interface\\Editor", CANCREATE, \
 
-     KEYEX(String,   Editor.Font.FontName, L"FontName2"); \
 
-     KEY(Integer,  Editor.Font.FontSize); \
 
-     KEY(Integer,  Editor.Font.FontStyle); \
 
-     KEY(Integer,  Editor.Font.FontCharset); \
 
-     KEY(Integer,  Editor.FontColor); \
 
-     KEY(Integer,  Editor.BackgroundColor); \
 
-     KEY(Bool,     Editor.WordWrap); \
 
-     KEY(String,   Editor.FindText); \
 
-     KEY(String,   Editor.ReplaceText); \
 
-     KEY(Bool,     Editor.FindMatchCase); \
 
-     KEY(Bool,     Editor.FindWholeWord); \
 
-     KEY(Bool,     Editor.FindDown); \
 
-     KEY(Integer,  Editor.TabSize); \
 
-     KEY(Integer,  Editor.MaxEditors); \
 
-     KEY(Integer,  Editor.EarlyClose); \
 
-     KEY(Bool,     Editor.SDIShellEditor); \
 
-     KEY(String,   Editor.WindowParams); \
 
-     KEY(Integer,  Editor.Encoding); \
 
-     KEY(Bool,     Editor.WarnOnEncodingFallback); \
 
-     KEY(Bool,     Editor.WarnOrLargeFileSize); \
 
-   ); \
 
-   BLOCK(L"Interface\\QueueView", CANCREATE, \
 
-     KEY(Integer,  QueueView.Height); \
 
-     KEY(Integer,  QueueView.HeightPixelsPerInch); \
 
-     KEY(String,   QueueView.Layout); \
 
-     KEY(Integer,  QueueView.Show); \
 
-     KEY(Integer,  QueueView.LastHideShow); \
 
-     KEY(Bool,     QueueView.ToolBar); \
 
-     KEY(Bool,     QueueView.Label); \
 
-   ); \
 
-   BLOCK(L"Interface\\Updates", CANCREATE, \
 
-     KEY(Integer,  FUpdates.Period); \
 
-     KEY(DateTime, FUpdates.LastCheck); \
 
-     KEY(Integer,  FUpdates.HaveResults); \
 
-     KEY(Integer,  FUpdates.ShownResults); \
 
-     KEY(Integer,  FUpdates.BetaVersions); \
 
-     KEY(Bool,     FUpdates.ShowOnStartup); \
 
-     KEY(String,   FUpdates.AuthenticationEmail); \
 
-     KEY(Integer,  FUpdates.ConnectionType); \
 
-     KEY(String,   FUpdates.ProxyHost); \
 
-     KEY(Integer,  FUpdates.ProxyPort); \
 
-     KEY(Integer,  FUpdates.Results.ForVersion); \
 
-     KEY(Integer,  FUpdates.Results.Version); \
 
-     KEY(String,   FUpdates.Results.Message); \
 
-     KEY(Integer,  FUpdates.Results.Critical); \
 
-     KEY(String,   FUpdates.Results.Release); \
 
-     KEY(Bool,     FUpdates.Results.Disabled); \
 
-     KEY(String,   FUpdates.Results.Url); \
 
-     KEY(String,   FUpdates.Results.UrlButton); \
 
-     KEY(String,   FUpdates.Results.NewsUrl); \
 
-     KEYEX(Integer,FUpdates.Results.NewsSize.Width, L"NewsWidth"); \
 
-     KEYEX(Integer,FUpdates.Results.NewsSize.Height, L"NewsHeight"); \
 
-     KEY(String,   FUpdates.Results.DownloadUrl); \
 
-     KEY(Int64,    FUpdates.Results.DownloadSize); \
 
-     KEY(String,   FUpdates.Results.DownloadSha256); \
 
-     KEY(String,   FUpdates.Results.AuthenticationError); \
 
-     KEY(Bool,     FUpdates.Results.OpenGettingStarted); \
 
-     KEY(String,   FUpdates.Results.DownloadingUrl); \
 
-     KEYEX(Integer,FUpdates.Results.TipsSize.Width, L"TipsWidth"); \
 
-     KEYEX(Integer,FUpdates.Results.TipsSize.Height, L"TipsHeight"); \
 
-     KEY(String,   FUpdates.Results.TipsUrl); \
 
-     KEY(String,   FUpdates.Results.Tips); \
 
-     KEY(Integer,  FUpdates.Results.TipsIntervalDays); \
 
-     KEY(Integer,  FUpdates.Results.TipsIntervalRuns); \
 
-     KEY(String,   FUpdates.DotNetVersion); \
 
-     KEY(String,   FUpdates.ConsoleVersion); \
 
-   ); \
 
-   BLOCK(L"Interface\\Explorer", CANCREATE, \
 
-     KEY(String,  ScpExplorer.ToolbarsLayout); \
 
-     KEY(String,  ScpExplorer.DirViewParams); \
 
-     KEY(String,  ScpExplorer.LastLocalTargetDirectory); \
 
-     KEY(Bool,    ScpExplorer.SessionsTabs); \
 
-     KEY(Bool,    ScpExplorer.StatusBar); \
 
-     KEY(String,  ScpExplorer.WindowParams); \
 
-     KEY(Integer, ScpExplorer.ViewStyle); \
 
-     KEY(Bool,    ScpExplorer.ShowFullAddress); \
 
-     KEY(Bool,    ScpExplorer.DriveView); \
 
-     KEY(Integer, ScpExplorer.DriveViewWidth); \
 
-     KEY(Integer, ScpExplorer.DriveViewWidthPixelsPerInch); \
 
-   ); \
 
-   BLOCK(L"Interface\\Commander", CANCREATE, \
 
-     KEY(String,  ScpCommander.ToolbarsLayout); \
 
-     KEY(Integer, ScpCommander.CurrentPanel); \
 
-     KEY(Float,   ScpCommander.LocalPanelWidth); \
 
-     KEY(Bool,    ScpCommander.SwappedPanels); \
 
-     KEY(Bool,    ScpCommander.SessionsTabs); \
 
-     KEY(Bool,    ScpCommander.StatusBar); \
 
-     KEY(String,  ScpCommander.WindowParams); \
 
-     KEYEX(Integer, ScpCommander.NortonLikeMode, L"ExplorerStyleSelection"); \
 
-     KEY(Bool,    ScpCommander.PreserveLocalDirectory); \
 
-     KEY(Bool,    ScpCommander.CompareByTime); \
 
-     KEY(Bool,    ScpCommander.CompareBySize); \
 
-     KEY(Bool,    ScpCommander.TreeOnLeft); \
 
-     KEY(Bool,    ScpCommander.ExplorerKeyboardShortcuts); \
 
-     KEY(Bool,    ScpCommander.SystemContextMenu); \
 
-   ); \
 
-   BLOCK(L"Interface\\Commander\\LocalPanel", CANCREATE, \
 
-     KEY(String,  ScpCommander.LocalPanel.DirViewParams); \
 
-     KEY(Bool,    ScpCommander.LocalPanel.StatusBar); \
 
-     KEY(Bool,    ScpCommander.LocalPanel.DriveView); \
 
-     KEY(Integer, ScpCommander.LocalPanel.DriveViewHeight); \
 
-     KEY(Integer, ScpCommander.LocalPanel.DriveViewHeightPixelsPerInch); \
 
-     KEY(Integer, ScpCommander.LocalPanel.DriveViewWidth); \
 
-     KEY(Integer, ScpCommander.LocalPanel.DriveViewWidthPixelsPerInch); \
 
-   ); \
 
-   BLOCK(L"Interface\\Commander\\RemotePanel", CANCREATE, \
 
-     KEY(String,  ScpCommander.RemotePanel.DirViewParams); \
 
-     KEY(Bool,    ScpCommander.RemotePanel.StatusBar); \
 
-     KEY(Bool,    ScpCommander.RemotePanel.DriveView); \
 
-     KEY(Integer, ScpCommander.RemotePanel.DriveViewHeight); \
 
-     KEY(Integer, ScpCommander.RemotePanel.DriveViewHeightPixelsPerInch); \
 
-     KEY(Integer, ScpCommander.RemotePanel.DriveViewWidth); \
 
-     KEY(Integer, ScpCommander.RemotePanel.DriveViewWidthPixelsPerInch); \
 
-   ); \
 
-   BLOCK(L"Logging", CANCREATE, \
 
-     KEY(Bool,    LogWindowOnStartup); \
 
-     KEY(String,  LogWindowParams); \
 
-   ); \
 
-   BLOCK(L"Security", CANCREATE, \
 
-     KEYEX(Bool,  FUseMasterPassword, L"UseMasterPassword"); \
 
-     KEYEX(String,FMasterPasswordVerifier, L"MasterPasswordVerifier"); \
 
-   );
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SaveData(THierarchicalStorage * Storage, bool All)
 
- {
 
-   TCustomWinConfiguration::SaveData(Storage, All);
 
-   // duplicated from core\configuration.cpp
 
-   #define KEYEX(TYPE, VAR, NAME) Storage->Write ## TYPE(NAME, VAR)
 
-   REGCONFIG(true);
 
-   #undef KEYEX
 
-   if (Storage->OpenSubKey(L"Bookmarks", true))
 
-   {
 
-     FBookmarks->Save(Storage, All);
 
-     Storage->CloseSubKey();
 
-   }
 
-   if ((All && !FCustomCommandsDefaults) || FCustomCommandList->Modified)
 
-   {
 
-     FCustomCommandList->Save(Storage);
 
-   }
 
-   if ((All || FEditorList->Modified) &&
 
-       Storage->OpenSubKey(L"Interface\\Editor", true, true))
 
-   try
 
-   {
 
-     FEditorList->Save(Storage);
 
-   }
 
-   __finally
 
-   {
 
-     Storage->CloseSubKey();
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::LoadFrom(THierarchicalStorage * Storage)
 
- {
 
-   FLegacyEditor = new TEditorPreferences();
 
-   try
 
-   {
 
-     FLegacyEditor->LegacyDefaults();
 
-     TCustomWinConfiguration::LoadFrom(Storage);
 
-     // This needs to be done even if there's no Configuration key in the storage,
 
-     // so it cannot be in LoadData
 
-     int EditorCount = FEditorList->Count;
 
-     if (EditorCount == 0)
 
-     {
 
-       TEditorPreferences * AlternativeEditor = NULL;
 
-       try
 
-       {
 
-         if (FLegacyEditor->Data->Editor == edInternal)
 
-         {
 
-           if (!FLegacyEditor->Data->ExternalEditor.IsEmpty())
 
-           {
 
-             AlternativeEditor = new TEditorPreferences(*FLegacyEditor);
 
-             AlternativeEditor->GetData()->Editor = edExternal;
 
-             FLegacyEditor->GetData()->ExternalEditor = L"";
 
-           }
 
-         }
 
-         else
 
-         {
 
-           if (FLegacyEditor->Data->ExternalEditor.IsEmpty())
 
-           {
 
-             FLegacyEditor->GetData()->Editor = edInternal;
 
-           }
 
-           else
 
-           {
 
-             AlternativeEditor = new TEditorPreferences(*FLegacyEditor);
 
-             AlternativeEditor->GetData()->Editor = edInternal;
 
-           }
 
-         }
 
-       }
 
-       catch(...)
 
-       {
 
-         delete AlternativeEditor;
 
-         throw;
 
-       }
 
-       FEditorList->Add(FLegacyEditor);
 
-       FLegacyEditor = NULL;
 
-       if (AlternativeEditor != NULL)
 
-       {
 
-         FEditorList->Add(AlternativeEditor);
 
-       }
 
-     }
 
-   }
 
-   __finally
 
-   {
 
-     delete FLegacyEditor;
 
-     FLegacyEditor = NULL;
 
-   }
 
-   if (FUpdates.ConnectionType == -1)
 
-   {
 
-     FUpdates.ConnectionType = (FUpdates.ProxyHost.IsEmpty() ? ctAuto : ctProxy);
 
-   }
 
-   AddVersionToHistory();
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::LoadData(THierarchicalStorage * Storage)
 
- {
 
-   TCustomWinConfiguration::LoadData(Storage);
 
-   // duplicated from core\configuration.cpp
 
-   #define KEYEX(TYPE, VAR, NAME) VAR = Storage->Read ## TYPE(NAME, VAR)
 
-   #pragma warn -eas
 
-   REGCONFIG(false);
 
-   #pragma warn +eas
 
-   #undef KEYEX
 
-   // to reflect changes to PanelFont
 
-   UpdateIconFont();
 
-   if (Storage->OpenSubKey(L"Bookmarks", false))
 
-   {
 
-     FBookmarks->Load(Storage);
 
-     Storage->CloseSubKey();
 
-   }
 
-   if (Storage->HasSubKey("CustomCommands"))
 
-   {
 
-     FCustomCommandList->Load(Storage);
 
-     FCustomCommandsDefaults = false;
 
-   }
 
-   else if (FCustomCommandList->Modified)
 
-   {
 
-     // can this (=reloading of configuration) even happen?
 
-     // if it does, shouldn't we reset default commands?
 
-     DebugFail();
 
-     FCustomCommandList->Clear();
 
-     FCustomCommandsDefaults = false;
 
-   }
 
-   FCustomCommandList->Reset();
 
-   if (Storage->OpenSubKey(L"Interface\\Editor", false, true))
 
-   try
 
-   {
 
-     FEditorList->Clear();
 
-     FEditorList->Load(Storage);
 
-   }
 
-   __finally
 
-   {
 
-     Storage->CloseSubKey();
 
-   }
 
-   // load legacy editor configuration
 
-   DebugAssert(FLegacyEditor != NULL);
 
-   if (Storage->OpenSubKey(L"Interface\\Editor", false, true))
 
-   {
 
-     try
 
-     {
 
-       FLegacyEditor->Load(Storage, true);
 
-     }
 
-     __finally
 
-     {
 
-       Storage->CloseSubKey();
 
-     }
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::LoadAdmin(THierarchicalStorage * Storage)
 
- {
 
-   TCustomWinConfiguration::LoadAdmin(Storage);
 
-   FDisableOpenEdit = Storage->ReadBool(L"DisableOpenEdit", FDisableOpenEdit);
 
-   FDefaultUpdatesPeriod = Storage->ReadInteger(L"DefaultUpdatesPeriod", FDefaultUpdatesPeriod);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::CopyData(THierarchicalStorage * Source, THierarchicalStorage * Target)
 
- {
 
-   TCustomWinConfiguration::CopyData(Source, Target);
 
-   if (Source->OpenSubKey(ConfigurationSubKey, false))
 
-   {
 
-     if (Target->OpenSubKey(ConfigurationSubKey, true))
 
-     {
 
-       Target->WriteString(L"JumpList", Source->ReadString(L"JumpList", L""));
 
-       Target->WriteString(L"JumpListWorkspaces", Source->ReadString(L"JumpListWorkspaces", L""));
 
-       Target->CloseSubKey();
 
-     }
 
-     Source->CloseSubKey();
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::ClearTemporaryLoginData()
 
- {
 
-   if (!FTemporaryKeyFile.IsEmpty())
 
-   {
 
-     DeleteFile(ApiPath(FTemporaryKeyFile));
 
-     FTemporaryKeyFile = L"";
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::AddVersionToHistory()
 
- {
 
-   int CurrentVersion = CompoundVersion;
 
-   int From = 1;
 
-   bool CurrentVersionPresent = false;
 
-   while (!CurrentVersionPresent && (From < FVersionHistory.Length()))
 
-   {
 
-     UnicodeString VersionInfo = CopyToChars(FVersionHistory, From, L";", true);
 
-     UnicodeString VersionStr = CutToChar(VersionInfo, L',', true);
 
-     int Version;
 
-     if (TryStrToInt(VersionStr, Version) &&
 
-         (Version == CurrentVersion))
 
-     {
 
-       CurrentVersionPresent = true;
 
-     }
 
-   }
 
-   if (!CurrentVersionPresent)
 
-   {
 
-     UnicodeString CurrentVersionInfo =
 
-       IntToStr(CurrentVersion) + L"," + GetReleaseType();
 
-     AddToList(FVersionHistory, CurrentVersionInfo, L';');
 
-   }
 
-   Usage->Set(L"AnyBetaUsed", AnyBetaInVersionHistory);
 
- }
 
- //---------------------------------------------------------------------------
 
- bool __fastcall TWinConfiguration::DoIsBeta(const UnicodeString & ReleaseType)
 
- {
 
-   // What about "Development" release type?
 
-   return AnsiSameText(ReleaseType, L"beta") || AnsiSameText(ReleaseType, L"rc");
 
- }
 
- //---------------------------------------------------------------------------
 
- bool __fastcall TWinConfiguration::GetIsBeta()
 
- {
 
-   return DoIsBeta(GetReleaseType());
 
- }
 
- //---------------------------------------------------------------------------
 
- TFont * __fastcall TWinConfiguration::GetSystemIconFont()
 
- {
 
-   // We should do live update from Screen->IconFont when custom panel font is not set
 
-   return FSystemIconFont.get();
 
- }
 
- //---------------------------------------------------------------------------
 
- bool __fastcall TWinConfiguration::GetAnyBetaInVersionHistory()
 
- {
 
-   int From = 1;
 
-   bool AnyBeta = false;
 
-   while (!AnyBeta && (From < VersionHistory.Length()))
 
-   {
 
-     UnicodeString VersionInfo = CopyToChars(VersionHistory, From, L";", true);
 
-     CutToChar(VersionInfo, L',', true);
 
-     UnicodeString ReleaseType = CutToChar(VersionInfo, ',', true);
 
-     if (DoIsBeta(ReleaseType))
 
-     {
 
-       AnyBeta = true;
 
-     }
 
-   }
 
-   return AnyBeta;
 
- }
 
- //---------------------------------------------------------------------------
 
- bool __fastcall TWinConfiguration::GetDDExtInstalled()
 
- {
 
-   if (FDDExtInstalled < 0)
 
-   {
 
-     if (IsWin64())
 
-     {
 
-       // WORKAROUND
 
-       // We cannot load 64-bit COM class into 32-bit process,
 
-       // so we fallback to querying registration keys
 
-       #define CLSID_SIZE 39
 
-       wchar_t ClassID[CLSID_SIZE];
 
-       StringFromGUID2(CLSID_ShellExtension, ClassID, LENOF(ClassID));
 
-       NULL_TERMINATE(ClassID);
 
-       UnicodeString SubKey = UnicodeString(L"CLSID\\") + ClassID;
 
-       HKEY HKey;
 
-       LONG Result = RegOpenKeyEx(HKEY_CLASSES_ROOT, SubKey.c_str(), 0, KEY_READ | KEY_WOW64_64KEY, &HKey);
 
-       if (Result == ERROR_SUCCESS)
 
-       {
 
-         RegCloseKey(HKey);
 
-         FDDExtInstalled = 1;
 
-       }
 
-       else
 
-       {
 
-         FDDExtInstalled = 0;
 
-       }
 
-     }
 
-     else
 
-     {
 
-       void * DragExtRef;
 
-       int CreateResult =
 
-         CoCreateInstance(CLSID_ShellExtension, NULL,
 
-           CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, IID_IUnknown,
 
-           &DragExtRef);
 
-       bool Result = (CreateResult == S_OK);
 
-       FDDExtInstalled = (Result ? 1 : 0);
 
-       if (Result)
 
-       {
 
-         reinterpret_cast<IUnknown *>(DragExtRef)->Release();
 
-         CoFreeUnusedLibraries();
 
-       }
 
-     }
 
-   }
 
-   return (FDDExtInstalled > 0);
 
- }
 
- //---------------------------------------------------------------------------
 
- RawByteString __fastcall TWinConfiguration::StronglyRecryptPassword(RawByteString Password, UnicodeString Key)
 
- {
 
-   RawByteString Dummy;
 
-   RawByteString Result;
 
-   if (GetExternalEncryptedPassword(Password, Dummy) ||
 
-       !FUseMasterPassword)
 
-   {
 
-     // already-strongly encrypted
 
-     // or no master password set, so we cannot strongly-encrypt it
 
-     Result = Password;
 
-   }
 
-   else
 
-   {
 
-     UnicodeString PasswordText =
 
-       TCustomWinConfiguration::DecryptPassword(Password, Key);
 
-     if (!PasswordText.IsEmpty())
 
-     {
 
-       // can be not set for instance, when editing=>saving site with no prior password
 
-       AskForMasterPasswordIfNotSet();
 
-       Password = ScramblePassword(PasswordText);
 
-       AES256EncyptWithMAC(Password, FPlainMasterPasswordEncrypt, Result);
 
-       Result = SetExternalEncryptedPassword(Result);
 
-     }
 
-   }
 
-   return Result;
 
- }
 
- //---------------------------------------------------------------------------
 
- UnicodeString __fastcall TWinConfiguration::DecryptPassword(RawByteString Password, UnicodeString Key)
 
- {
 
-   UnicodeString Result;
 
-   RawByteString Buf;
 
-   if (GetExternalEncryptedPassword(Password, Buf))
 
-   {
 
-     if (FDontDecryptPasswords == 0)
 
-     {
 
-       // As opposite to AskForMasterPasswordIfNotSet, we test here
 
-       // for decrypt password. This is important while recrypting password,
 
-       // when clearing master password, when encrypt password is already empty.
 
-       if (FPlainMasterPasswordDecrypt.IsEmpty())
 
-       {
 
-         AskForMasterPassword();
 
-       }
 
-       if (!AES256DecryptWithMAC(Buf, FPlainMasterPasswordDecrypt, Buf) ||
 
-           !UnscramblePassword(Buf, Result))
 
-       {
 
-         throw Exception(LoadStr(DECRYPT_PASSWORD_ERROR));
 
-       }
 
-     }
 
-     else
 
-     {
 
-       Abort();
 
-     }
 
-   }
 
-   else
 
-   {
 
-     Result = TCustomWinConfiguration::DecryptPassword(Password, Key);
 
-   }
 
-   return Result;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetMasterPassword(UnicodeString value)
 
- {
 
-   // just stores the plain-text version of the password
 
-   // we can get here even if master password is off,
 
-   // when we encounter stray encrypted password (e.g. manually imported site),
 
-   // make sure we do not set encrypt password to avoid starting encrypting
 
-   // new passwords
 
-   // (this is bit of edge case, not really well tested)
 
-   if (!FUseMasterPassword)
 
-   {
 
-     FPlainMasterPasswordDecrypt = value;
 
-   }
 
-   else if (DebugAlwaysTrue(FUseMasterPassword) &&
 
-       DebugAlwaysTrue(ValidateMasterPassword(value)))
 
-   {
 
-     FPlainMasterPasswordEncrypt = value;
 
-     FPlainMasterPasswordDecrypt = value;
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::ChangeMasterPassword(
 
-   UnicodeString value, TStrings * RecryptPasswordErrors)
 
- {
 
-   RawByteString Verifier;
 
-   AES256CreateVerifier(value, Verifier);
 
-   FMasterPasswordVerifier = BytesToHex(Verifier);
 
-   FPlainMasterPasswordEncrypt = value;
 
-   FUseMasterPassword = true;
 
-   try
 
-   {
 
-     RecryptPasswords(RecryptPasswordErrors);
 
-   }
 
-   __finally
 
-   {
 
-     FPlainMasterPasswordDecrypt = value;
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- bool __fastcall TWinConfiguration::ValidateMasterPassword(UnicodeString value)
 
- {
 
-   DebugAssert(UseMasterPassword);
 
-   DebugAssert(!FMasterPasswordVerifier.IsEmpty());
 
-   bool Result = AES256Verify(value, HexToBytes(FMasterPasswordVerifier));
 
-   return Result;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::ClearMasterPassword(TStrings * RecryptPasswordErrors)
 
- {
 
-   FMasterPasswordVerifier = L"";
 
-   FUseMasterPassword = false;
 
-   Shred(FPlainMasterPasswordEncrypt);
 
-   try
 
-   {
 
-     RecryptPasswords(RecryptPasswordErrors);
 
-   }
 
-   __finally
 
-   {
 
-     Shred(FPlainMasterPasswordDecrypt);
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::AskForMasterPassword()
 
- {
 
-   if (FMasterPasswordSession > 0)
 
-   {
 
-     if (FMasterPasswordSessionAsked)
 
-     {
 
-       Abort();
 
-     }
 
-     // set before call to OnMasterPasswordPrompt as it may abort
 
-     FMasterPasswordSessionAsked = true;
 
-   }
 
-   if (FOnMasterPasswordPrompt == NULL)
 
-   {
 
-     throw Exception(L"Master password handler not set");
 
-   }
 
-   else
 
-   {
 
-     FOnMasterPasswordPrompt();
 
-     DebugAssert(!FPlainMasterPasswordDecrypt.IsEmpty());
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::AskForMasterPasswordIfNotSet()
 
- {
 
-   if (FPlainMasterPasswordEncrypt.IsEmpty())
 
-   {
 
-     AskForMasterPassword();
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::BeginMasterPasswordSession()
 
- {
 
-   // We do not expect nesting
 
-   DebugAssert(FMasterPasswordSession == 0);
 
-   DebugAssert(!FMasterPasswordSessionAsked || (FMasterPasswordSession > 0));
 
-   // This should better be thread-specific
 
-   FMasterPasswordSession++;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::EndMasterPasswordSession()
 
- {
 
-   if (DebugAlwaysTrue(FMasterPasswordSession > 0))
 
-   {
 
-     FMasterPasswordSession--;
 
-   }
 
-   FMasterPasswordSessionAsked = false;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetLogWindowOnStartup(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(LogWindowOnStartup);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetLogWindowParams(UnicodeString value)
 
- {
 
-   SET_CONFIG_PROPERTY(LogWindowParams);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetDDAllowMove(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(DDAllowMove);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetDDAllowMoveInit(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(DDAllowMoveInit);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetDDTransferConfirmation(TAutoSwitch value)
 
- {
 
-   SET_CONFIG_PROPERTY(DDTransferConfirmation);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetDDTemporaryDirectory(UnicodeString value)
 
- {
 
-   SET_CONFIG_PROPERTY(DDTemporaryDirectory);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetDDExtEnabled(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(DDExtEnabled);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetDDExtTimeout(int value)
 
- {
 
-   SET_CONFIG_PROPERTY(DDExtTimeout);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetDDWarnLackOfTempSpace(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(DDWarnLackOfTempSpace);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetDDWarnLackOfTempSpaceRatio(double value)
 
- {
 
-   SET_CONFIG_PROPERTY(DDWarnLackOfTempSpaceRatio);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetScpExplorer(TScpExplorerConfiguration value)
 
- {
 
-   SET_CONFIG_PROPERTY(ScpExplorer);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetScpCommander(TScpCommanderConfiguration value)
 
- {
 
-   SET_CONFIG_PROPERTY(ScpCommander);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetEditor(TEditorConfiguration value)
 
- {
 
-   SET_CONFIG_PROPERTY(Editor);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetQueueView(TQueueViewConfiguration value)
 
- {
 
-   SET_CONFIG_PROPERTY(QueueView);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetEnableQueueByDefault(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(EnableQueueByDefault);
 
- }
 
- //---------------------------------------------------------------------------
 
- TUpdatesConfiguration __fastcall TWinConfiguration::GetUpdates()
 
- {
 
-   TUpdatesConfiguration Result;
 
-   {
 
-     TGuard Guard(FCriticalSection);
 
-     Result = FUpdates;
 
-   }
 
-   return Result;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetUpdates(TUpdatesConfiguration value)
 
- {
 
-   TGuard Guard(FCriticalSection);
 
-   // do not use SET_CONFIG_PROPERTY to avoid OnChange handler call (not synchronized)
 
-   FUpdates = value;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetVersionHistory(UnicodeString value)
 
- {
 
-   SET_CONFIG_PROPERTY(VersionHistory);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetDeleteToRecycleBin(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(DeleteToRecycleBin);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetSelectDirectories(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(SelectDirectories);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetShowHiddenFiles(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(ShowHiddenFiles);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetFormatSizeBytes(TFormatBytesStyle value)
 
- {
 
-   SET_CONFIG_PROPERTY(FormatSizeBytes);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetShowInaccesibleDirectories(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(ShowInaccesibleDirectories);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetConfirmTransferring(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(ConfirmTransferring);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetConfirmDeleting(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(ConfirmDeleting);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetConfirmRecycling(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(ConfirmRecycling);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetUseLocationProfiles(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(UseLocationProfiles);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetUseSharedBookmarks(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(UseSharedBookmarks);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetConfirmClosingSession(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(ConfirmClosingSession);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetDoubleClickAction(TDoubleClickAction value)
 
- {
 
-   SET_CONFIG_PROPERTY(DoubleClickAction);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetCopyOnDoubleClickConfirmation(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(CopyOnDoubleClickConfirmation);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetDimmHiddenFiles(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(DimmHiddenFiles);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetRenameWholeName(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(RenameWholeName);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetAutoStartSession(UnicodeString value)
 
- {
 
-   SET_CONFIG_PROPERTY(AutoStartSession);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetExpertMode(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(ExpertMode);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetDefaultDirIsHome(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(DefaultDirIsHome);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetTemporaryDirectoryAppendSession(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(TemporaryDirectoryAppendSession);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetTemporaryDirectoryAppendPath(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(TemporaryDirectoryAppendPath);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetTemporaryDirectoryDeterministic(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(TemporaryDirectoryDeterministic);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetTemporaryDirectoryCleanup(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(TemporaryDirectoryCleanup);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetConfirmTemporaryDirectoryCleanup(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(ConfirmTemporaryDirectoryCleanup);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetPreservePanelState(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(PreservePanelState);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetLastStoredSession(UnicodeString value)
 
- {
 
-   SET_CONFIG_PROPERTY(LastStoredSession);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetAutoSaveWorkspace(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(AutoSaveWorkspace);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetAutoSaveWorkspacePasswords(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(AutoSaveWorkspacePasswords);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetAutoWorkspace(UnicodeString value)
 
- {
 
-   SET_CONFIG_PROPERTY(AutoWorkspace);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetPathInCaption(TPathInCaption value)
 
- {
 
-   SET_CONFIG_PROPERTY(PathInCaption);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetMinimizeToTray(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(MinimizeToTray);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::MinimizeToTrayOnce()
 
- {
 
-   FMinimizeToTrayOnce = true;
 
- }
 
- //---------------------------------------------------------------------------
 
- bool __fastcall TWinConfiguration::GetMinimizeToTray()
 
- {
 
-   bool Result = FMinimizeToTrayOnce || FMinimizeToTray;
 
-   FMinimizeToTrayOnce = false;
 
-   return Result;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetBalloonNotifications(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(BalloonNotifications);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetNotificationsTimeout(unsigned int value)
 
- {
 
-   SET_CONFIG_PROPERTY(NotificationsTimeout);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetNotificationsStickTime(unsigned int value)
 
- {
 
-   SET_CONFIG_PROPERTY(NotificationsStickTime);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetCopyParamAutoSelectNotice(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(CopyParamAutoSelectNotice);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetLockToolbars(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(LockToolbars);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetSelectiveToolbarText(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(SelectiveToolbarText);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetAutoOpenInPutty(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(AutoOpenInPutty);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetRefreshRemotePanel(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(RefreshRemotePanel);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetRefreshRemotePanelInterval(TDateTime value)
 
- {
 
-   SET_CONFIG_PROPERTY(RefreshRemotePanelInterval);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::UpdateSystemIconFont()
 
- {
 
-   FSystemIconFont->Assign(Screen->IconFont);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::UpdateIconFont()
 
- {
 
-   if (!PanelFont.FontName.IsEmpty())
 
-   {
 
-     UpdateSystemIconFont();
 
-     std::unique_ptr<TFont> IconFont(new TFont());
 
-     RestoreFont(PanelFont, IconFont.get());
 
-     Screen->IconFont->Assign(IconFont.get());
 
-     // When using non-standard icon font, prevent resetting it back
 
-     // to standard one on WM_WININICHANGE. Unfortunatelly this prevents
 
-     // updating all other fonts.
 
-     Application->UpdateMetricSettings = false;
 
-   }
 
-   else
 
-   {
 
-     if (DebugAlwaysTrue(FSystemIconFont.get() != NULL) &&
 
-         !SameFont(Screen->IconFont, FSystemIconFont.get()))
 
-     {
 
-       Screen->IconFont->Assign(FSystemIconFont.get());
 
-     }
 
-     Application->UpdateMetricSettings = true;
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetPanelFont(const TFontConfiguration & value)
 
- {
 
-   SET_CONFIG_PROPERTY_EX(PanelFont, UpdateIconFont());
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetFullRowSelect(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(FullRowSelect);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetOfferedEditorAutoConfig(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(OfferedEditorAutoConfig);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetOpenedStoredSessionFolders(UnicodeString value)
 
- {
 
-   SET_CONFIG_PROPERTY(OpenedStoredSessionFolders);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetAutoImportedFromPuttyOrFilezilla(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(AutoImportedFromPuttyOrFilezilla);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetGenerateUrlComponents(int value)
 
- {
 
-   SET_CONFIG_PROPERTY(GenerateUrlComponents);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetGenerateUrlCodeTarget(TGenerateUrlCodeTarget value)
 
- {
 
-   SET_CONFIG_PROPERTY(GenerateUrlCodeTarget);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetGenerateUrlScriptFormat(TScriptFormat value)
 
- {
 
-   SET_CONFIG_PROPERTY(GenerateUrlScriptFormat);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetGenerateUrlAssemblyLanguage(TAssemblyLanguage value)
 
- {
 
-   SET_CONFIG_PROPERTY(GenerateUrlAssemblyLanguage);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetExternalSessionInExistingInstance(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(ExternalSessionInExistingInstance);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetKeepOpenWhenNoSession(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(KeepOpenWhenNoSession);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetLocalIconsByExt(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(LocalIconsByExt);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetBidiModeOverride(TLocaleFlagOverride value)
 
- {
 
-   SET_CONFIG_PROPERTY(BidiModeOverride);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetFlipChildrenOverride(TLocaleFlagOverride value)
 
- {
 
-   SET_CONFIG_PROPERTY(FlipChildrenOverride);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetShowTips(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(ShowTips);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetTipsSeen(UnicodeString value)
 
- {
 
-   SET_CONFIG_PROPERTY(TipsSeen);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetTipsShown(TDateTime value)
 
- {
 
-   SET_CONFIG_PROPERTY(TipsShown);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetRunsSinceLastTip(int value)
 
- {
 
-   SET_CONFIG_PROPERTY(RunsSinceLastTip);
 
- }
 
- //---------------------------------------------------------------------------
 
- bool __fastcall TWinConfiguration::GetHonorDrivePolicy()
 
- {
 
-   return DriveInfo->HonorDrivePolicy;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetHonorDrivePolicy(bool value)
 
- {
 
-   if (HonorDrivePolicy != value)
 
-   {
 
-     DriveInfo->HonorDrivePolicy = value;
 
-     Changed();
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetCustomCommandList(TCustomCommandList * value)
 
- {
 
-   DebugAssert(FCustomCommandList);
 
-   if (!FCustomCommandList->Equals(value))
 
-   {
 
-     FCustomCommandList->Assign(value);
 
-     FCustomCommandsDefaults = false;
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetBookmarks(UnicodeString Key,
 
-   TBookmarkList * value)
 
- {
 
-   FBookmarks->Bookmarks[Key] = value;
 
-   Changed();
 
- }
 
- //---------------------------------------------------------------------------
 
- TBookmarkList * __fastcall TWinConfiguration::GetBookmarks(UnicodeString Key)
 
- {
 
-   return FBookmarks->Bookmarks[Key];
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetSharedBookmarks(TBookmarkList * value)
 
- {
 
-   FBookmarks->SharedBookmarks = value;
 
-   Changed();
 
- }
 
- //---------------------------------------------------------------------------
 
- TBookmarkList * __fastcall TWinConfiguration::GetSharedBookmarks()
 
- {
 
-   return FBookmarks->SharedBookmarks;
 
- }
 
- //---------------------------------------------------------------------------
 
- UnicodeString __fastcall TWinConfiguration::GetDefaultKeyFile()
 
- {
 
-   return (!FDefaultKeyFile.IsEmpty() ? FDefaultKeyFile : FTemporaryKeyFile);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetLastMonitor(int value)
 
- {
 
-   ::SetLastMonitor(value);
 
- }
 
- //---------------------------------------------------------------------------
 
- int __fastcall TWinConfiguration::GetLastMonitor()
 
- {
 
-   return ::GetLastMonitor();
 
- }
 
- //---------------------------------------------------------------------------
 
- UnicodeString __fastcall TWinConfiguration::ExpandedTemporaryDirectory()
 
- {
 
-   UnicodeString Result =
 
-     ExpandFileName(ExpandEnvironmentVariables(DDTemporaryDirectory));
 
-   if (Result.IsEmpty())
 
-   {
 
-     Result = SystemTemporaryDirectory();
 
-   }
 
-   return Result;
 
- }
 
- //---------------------------------------------------------------------------
 
- UnicodeString __fastcall TWinConfiguration::TemporaryDir(bool Mask)
 
- {
 
-   return UniqTempDir(ExpandedTemporaryDirectory(), L"scp", Mask);
 
- }
 
- //---------------------------------------------------------------------------
 
- TStrings * __fastcall TWinConfiguration::FindTemporaryFolders()
 
- {
 
-   TStrings * Result = new TStringList();
 
-   try
 
-   {
 
-     TSearchRecChecked SRec;
 
-     UnicodeString Mask = TemporaryDir(true);
 
-     UnicodeString Directory = ExtractFilePath(Mask);
 
-     if (FindFirstUnchecked(Mask, faDirectory, SRec) == 0)
 
-     {
 
-       do
 
-       {
 
-         if (FLAGSET(SRec.Attr, faDirectory))
 
-         {
 
-           Result->Add(Directory + SRec.Name);
 
-         }
 
-       }
 
-       while (FindNextChecked(SRec) == 0);
 
-     }
 
-     if (Result->Count == 0)
 
-     {
 
-       delete Result;
 
-       Result = NULL;
 
-     }
 
-   }
 
-   catch(...)
 
-   {
 
-     delete Result;
 
-     throw;
 
-   }
 
-   return Result;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::CleanupTemporaryFolders(TStrings * Folders)
 
- {
 
-   UnicodeString ErrorList;
 
-   TStrings * F;
 
-   if (Folders == NULL)
 
-   {
 
-     F = FindTemporaryFolders();
 
-   }
 
-   else
 
-   {
 
-     F = Folders;
 
-   }
 
-   if (F != NULL)
 
-   {
 
-     try
 
-     {
 
-       if (DebugAlwaysTrue(F->Count > 0))
 
-       {
 
-         Usage->Inc(L"TemporaryDirectoryCleanups");
 
-       }
 
-       for (int i = 0; i < F->Count; i++)
 
-       {
 
-         if (!DeleteDirectory(F->Strings[i]))
 
-         {
 
-           if (!ErrorList.IsEmpty())
 
-           {
 
-             ErrorList += L"\n";
 
-           }
 
-           ErrorList += F->Strings[i];
 
-         }
 
-       }
 
-     }
 
-     __finally
 
-     {
 
-       if (Folders == NULL)
 
-       {
 
-         delete F;
 
-       }
 
-     }
 
-     if (!ErrorList.IsEmpty())
 
-     {
 
-       throw ExtException(LoadStr(CLEANUP_TEMP_ERROR), ErrorList);
 
-     }
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- LCID __fastcall TWinConfiguration::GetLocale()
 
- {
 
-   if (!FLocale)
 
-   {
 
-     UnicodeString ResourceModule =
 
-       GetResourceModuleName(Application->Name, ModuleFileName().c_str());
 
-     if (!ResourceModule.IsEmpty())
 
-     {
 
-       UnicodeString ResourceExt = ExtractFileExt(ResourceModule).UpperCase();
 
-       ResourceExt.Delete(1, 1);
 
-       TLanguages * Langs = Languages();
 
-       int Index, Count;
 
-       Count = Langs->Count;
 
-       Index = 0;
 
-       while ((Index < Count) && (FLocale == 0))
 
-       {
 
-         if (Langs->Ext[Index] == ResourceExt)
 
-         {
 
-           SetInitialLocale(Langs->LocaleID[Index]);
 
-         }
 
-         else if (Langs->Ext[Index].SubString(1, 2) == ResourceExt)
 
-         {
 
-           SetInitialLocale(
 
-             MAKELANGID(PRIMARYLANGID(Langs->LocaleID[Index]),
 
-               SUBLANG_DEFAULT));
 
-         }
 
-         if (FLocale != 0)
 
-         {
 
-           FLocaleModuleName = ResourceModule;
 
-         }
 
-         Index++;
 
-       }
 
-     }
 
-   }
 
-   return TCustomWinConfiguration::GetLocale();
 
- }
 
- //---------------------------------------------------------------------------
 
- HINSTANCE __fastcall TWinConfiguration::LoadNewResourceModule(LCID ALocale,
 
-   UnicodeString & FileName)
 
- {
 
-   HINSTANCE Instance = TCustomWinConfiguration::LoadNewResourceModule(ALocale, FileName);
 
-   if (Instance != NULL)
 
-   {
 
-     try
 
-     {
 
-       CheckTranslationVersion(FileName, false);
 
-     }
 
-     catch(...)
 
-     {
 
-       FreeResourceModule(Instance);
 
-       throw;
 
-     }
 
-   }
 
-   return Instance;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::CheckTranslationVersion(const UnicodeString FileName,
 
-   bool InternalLocaleOnError)
 
- {
 
-   UnicodeString TranslationProductVersion = GetFileProductVersion(FileName);
 
-   UnicodeString TranslationProductName = GetFileProductName(FileName);
 
-   if ((ProductName != TranslationProductName) ||
 
-       (ProductVersion != TranslationProductVersion))
 
-   {
 
-     if (InternalLocaleOnError)
 
-     {
 
-       LocaleSafe = InternalLocale();
 
-     }
 
-     if (TranslationProductName.IsEmpty() || TranslationProductVersion.IsEmpty())
 
-     {
 
-       throw Exception(FMTLOAD(UNKNOWN_TRANSLATION, (FileName)));
 
-     }
 
-     else
 
-     {
 
-       throw Exception(FMTLOAD(INCOMPATIBLE_TRANSLATION,
 
-         (FileName, TranslationProductName, TranslationProductVersion)));
 
-     }
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::CheckDefaultTranslation()
 
- {
 
-   if (!FInvalidDefaultTranslationMessage.IsEmpty())
 
-   {
 
-     MoreMessageDialog(FMTLOAD(INVALID_DEFAULT_TRANSLATION,
 
-       (FInvalidDefaultTranslationMessage)), NULL, qtWarning, qaOK, HELP_NONE);
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- const TEditorPreferences * __fastcall TWinConfiguration::DefaultEditorForFile(
 
-   const UnicodeString FileName, bool Local, const TFileMasks::TParams & MaskParams)
 
- {
 
-   return FEditorList->Find(FileName, Local, MaskParams);
 
- }
 
- //---------------------------------------------------------------------------
 
- const TEditorList * __fastcall TWinConfiguration::GetEditorList()
 
- {
 
-   return FEditorList;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SetEditorList(const TEditorList * value)
 
- {
 
-   if (!(*FEditorList == *value))
 
-   {
 
-     *FEditorList = *value;
 
-     Changed();
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- TStringList * __fastcall TWinConfiguration::LoadJumpList(
 
-   THierarchicalStorage * Storage, UnicodeString Name)
 
- {
 
-   UnicodeString JumpList = Storage->ReadString(Name, L"");
 
-   std::unique_ptr<TStringList> List(new TStringList());
 
-   List->CaseSensitive = false;
 
-   List->CommaText = JumpList;
 
-   return List.release();
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::SaveJumpList(
 
-   THierarchicalStorage * Storage, UnicodeString Name, TStringList * List)
 
- {
 
-   UnicodeString JumpList = Storage->ReadString(Name, L"");
 
-   UnicodeString NewJumpList = List->CommaText;
 
-   if (NewJumpList != JumpList)
 
-   {
 
-     Storage->WriteString(Name, NewJumpList);
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::TrimJumpList(TStringList * List)
 
- {
 
-   while (List->Count > 30)
 
-   {
 
-     List->Delete(List->Count - 1);
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::UpdateEntryInJumpList(
 
-   bool Session, const UnicodeString & Name, bool Add)
 
- {
 
-   THierarchicalStorage * Storage = CreateConfigStorage();
 
-   try
 
-   {
 
-     FDontDecryptPasswords++;
 
-     Storage->AccessMode = smReadWrite;
 
-     if (Storage->OpenSubKey(ConfigurationSubKey, true))
 
-     {
 
-       std::unique_ptr<TStringList> ListSessions(LoadJumpList(Storage, L"JumpList"));
 
-       std::unique_ptr<TStringList> ListWorkspaces(LoadJumpList(Storage, L"JumpListWorkspaces"));
 
-       if (!Name.IsEmpty())
 
-       {
 
-         TStringList * List = (Session ? ListSessions : ListWorkspaces).get();
 
-         int Index = List->IndexOf(Name);
 
-         if (Index >= 0)
 
-         {
 
-           List->Delete(Index);
 
-         }
 
-         if (Add)
 
-         {
 
-           List->Insert(0, Name);
 
-         }
 
-       }
 
-       TrimJumpList(ListSessions.get());
 
-       TrimJumpList(ListWorkspaces.get());
 
-       ::UpdateJumpList(ListSessions.get(), ListWorkspaces.get());
 
-       SaveJumpList(Storage, L"JumpList", ListSessions.get());
 
-       SaveJumpList(Storage, L"JumpListWorkspaces", ListWorkspaces.get());
 
-     }
 
-   }
 
-   __finally
 
-   {
 
-     FDontDecryptPasswords--;
 
-     delete Storage;
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::AddSessionToJumpList(UnicodeString SessionName)
 
- {
 
-   UpdateEntryInJumpList(true, SessionName, true);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::DeleteSessionFromJumpList(UnicodeString SessionName)
 
- {
 
-   UpdateEntryInJumpList(true, SessionName, false);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::AddWorkspaceToJumpList(UnicodeString Workspace)
 
- {
 
-   UpdateEntryInJumpList(false, Workspace, true);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::DeleteWorkspaceFromJumpList(UnicodeString Workspace)
 
- {
 
-   UpdateEntryInJumpList(false, Workspace, false);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::UpdateJumpList()
 
- {
 
-   AddSessionToJumpList(L"");
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::UpdateStaticUsage()
 
- {
 
-   // This is here because of TStoredSessionList::UpdateStaticUsage() call
 
-   // from TConfiguration::UpdateStaticUsage()
 
-   TAutoNestingCounter DontDecryptPasswordsAutoCounter(FDontDecryptPasswords);
 
-   TCustomWinConfiguration::UpdateStaticUsage();
 
-   Usage->Set(L"Beta", IsBeta);
 
-   Usage->Set(L"Interface", Interface);
 
-   Usage->Set(L"CustomCommandsCount", (FCustomCommandsDefaults ? 0 : FCustomCommandList->Count));
 
-   Usage->Set(L"UsingLocationProfiles", UseLocationProfiles);
 
-   Usage->Set(L"UsingMasterPassword", UseMasterPassword);
 
-   Usage->Set(L"UsingAutoSaveWorkspace", AutoSaveWorkspace);
 
-   Usage->Set(L"TreeVisible",
 
-     (Interface == ifExplorer) ?
 
-       ScpExplorer.DriveView :
 
-       (ScpCommander.LocalPanel.DriveView || ScpCommander.RemotePanel.DriveView));
 
-   Usage->Set(L"MinimizeToTray", MinimizeToTray);
 
-   Usage->Set(L"ShowingTips", ShowTips);
 
-   TipsUpdateStaticUsage();
 
-   Usage->Set(L"CommanderNortonLikeMode", int(ScpCommander.NortonLikeMode));
 
-   Usage->Set(L"CommanderExplorerKeyboardShortcuts", ScpCommander.ExplorerKeyboardShortcuts);
 
-   Usage->Set(L"ExplorerViewStyle", ScpExplorer.ViewStyle);
 
-   Usage->Set(L"LastMonitor", LastMonitor);
 
-   UnicodeString ExternalEditors;
 
-   for (int Index = 0; Index < EditorList->Count; Index++)
 
-   {
 
-     const TEditorPreferences * Editor = EditorList->Editors[Index];
 
-     if (Editor->Data->Editor == edExternal)
 
-     {
 
-       AddToList(ExternalEditors, Editor->ExtractExternalEditorName(), ",");
 
-     }
 
-   }
 
-   Usage->Set(L"ExternalEditors", ExternalEditors);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::RestoreFont(
 
-   const TFontConfiguration & Configuration, TFont * Font)
 
- {
 
-   Font->Name = Configuration.FontName;
 
-   Font->Size = Configuration.FontSize;
 
-   Font->Charset = Configuration.FontCharset;
 
-   Font->Style = IntToFontStyles(Configuration.FontStyle);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TWinConfiguration::StoreFont(
 
-   TFont * Font, TFontConfiguration & Configuration)
 
- {
 
-   Configuration.FontName = Font->Name;
 
-   Configuration.FontSize = Font->Size;
 
-   Configuration.FontCharset = Font->Charset;
 
-   Configuration.FontStyle = FontStylesToInt(Font->Style);
 
- }
 
- //---------------------------------------------------------------------------
 
- //---------------------------------------------------------------------------
 
- __fastcall TCustomCommandType::TCustomCommandType() :
 
-   FParams(0), FShortCut(0)
 
- {
 
- }
 
- //---------------------------------------------------------------------------
 
- __fastcall TCustomCommandType::TCustomCommandType(const TCustomCommandType & Other) :
 
-   FName(Other.FName),
 
-   FCommand(Other.FCommand),
 
-   FParams(Other.FParams),
 
-   FShortCut(Other.FShortCut)
 
- {
 
- }
 
- //---------------------------------------------------------------------------
 
- TCustomCommandType & TCustomCommandType::operator=(const TCustomCommandType & Other)
 
- {
 
-   FName = Other.FName;
 
-   FCommand = Other.FCommand;
 
-   FParams = Other.FParams;
 
-   FShortCut = Other.FShortCut;
 
-   return *this;
 
- }
 
- //---------------------------------------------------------------------------
 
- bool __fastcall TCustomCommandType::Equals(const TCustomCommandType * Other) const
 
- {
 
-   return
 
-     (FName == Other->FName) &&
 
-     (FCommand == Other->FCommand) &&
 
-     (FParams == Other->FParams) &&
 
-     (FShortCut == Other->FShortCut);
 
- }
 
- //---------------------------------------------------------------------------
 
- //---------------------------------------------------------------------------
 
- __fastcall TCustomCommandList::TCustomCommandList()
 
- {
 
-   FCommands = new TList();
 
-   FModified = false;
 
- }
 
- //---------------------------------------------------------------------------
 
- __fastcall TCustomCommandList::~TCustomCommandList()
 
- {
 
-   Clear();
 
-   delete FCommands;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TCustomCommandList::Reset()
 
- {
 
-   FModified = false;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TCustomCommandList::Modify()
 
- {
 
-   FModified = true;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TCustomCommandList::Load(THierarchicalStorage * Storage)
 
- {
 
-   Clear();
 
-   if (Storage->OpenSubKey(L"CustomCommands", false))
 
-   {
 
-     TStrings * Names = new TStringList();
 
-     try
 
-     {
 
-       Storage->ReadValues(Names, true);
 
-       for (int Index = 0; Index < Names->Count; Index++)
 
-       {
 
-         TCustomCommandType * Command = new TCustomCommandType();
 
-         Command->Name = Names->Names[Index];
 
-         Command->Command = Names->Values[Names->Names[Index]];
 
-         FCommands->Add(Command);
 
-       }
 
-       Storage->CloseSubKey();
 
-     }
 
-     __finally
 
-     {
 
-       delete Names;
 
-     }
 
-   }
 
-   if (Storage->OpenSubKey(L"CustomCommandsParams", false))
 
-   {
 
-     for (int Index = 0; Index < FCommands->Count; Index++)
 
-     {
 
-       TCustomCommandType * Command = GetCommand(Index);
 
-       Command->Params = Storage->ReadInteger(Command->Name, Command->Params);
 
-     }
 
-     Storage->CloseSubKey();
 
-   }
 
-   if (Storage->OpenSubKey(L"CustomCommandsShortCuts", false))
 
-   {
 
-     for (int Index = 0; Index < FCommands->Count; Index++)
 
-     {
 
-       TCustomCommandType * Command = GetCommand(Index);
 
-       Command->ShortCut = (Word)Storage->ReadInteger(Command->Name, Command->ShortCut);
 
-     }
 
-     Storage->CloseSubKey();
 
-   }
 
-   Reset();
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TCustomCommandList::Save(THierarchicalStorage * Storage)
 
- {
 
-   if (Storage->OpenSubKey(L"CustomCommands", true))
 
-   {
 
-     Storage->ClearValues();
 
-     for (int Index = 0; Index < FCommands->Count; Index++)
 
-     {
 
-       const TCustomCommandType * Command = Commands[Index];
 
-       Storage->WriteString(Command->Name, Command->Command);
 
-     }
 
-     Storage->CloseSubKey();
 
-   }
 
-   if (Storage->OpenSubKey(L"CustomCommandsParams", true))
 
-   {
 
-     Storage->ClearValues();
 
-     for (int Index = 0; Index < FCommands->Count; Index++)
 
-     {
 
-       const TCustomCommandType * Command = Commands[Index];
 
-       Storage->WriteInteger(Command->Name, Command->Params);
 
-     }
 
-     Storage->CloseSubKey();
 
-   }
 
-   if (Storage->OpenSubKey(L"CustomCommandsShortCuts", true))
 
-   {
 
-     Storage->ClearValues();
 
-     for (int Index = 0; Index < FCommands->Count; Index++)
 
-     {
 
-       const TCustomCommandType * Command = Commands[Index];
 
-       if (Command->ShortCut != 0)
 
-       {
 
-         Storage->WriteInteger(Command->Name, Command->ShortCut);
 
-       }
 
-     }
 
-     Storage->CloseSubKey();
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TCustomCommandList::Clear()
 
- {
 
-   for (int Index = 0; Index < FCommands->Count; Index++)
 
-   {
 
-     delete Commands[Index];
 
-   }
 
-   FCommands->Clear();
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TCustomCommandList::Add(const UnicodeString Name,
 
-   const UnicodeString ACommand, int Params)
 
- {
 
-   TCustomCommandType * Command = new TCustomCommandType();
 
-   Command->Name = Name;
 
-   Command->Command = ACommand;
 
-   Command->Params = Params;
 
-   Add(Command);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TCustomCommandList::Add(TCustomCommandType * Command)
 
- {
 
-   Insert(Count, Command);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TCustomCommandList::Insert(int Index, TCustomCommandType * Command)
 
- {
 
-   FCommands->Insert(Index, Command);
 
-   Modify();
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TCustomCommandList::Change(int Index, TCustomCommandType * ACommand)
 
- {
 
-   TCustomCommandType * Command = GetCommand(Index);
 
-   if (!Command->Equals(ACommand))
 
-   {
 
-     delete Command;
 
-     FCommands->Items[Index] = ACommand;
 
-     Modify();
 
-   }
 
-   else
 
-   {
 
-     delete ACommand;
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TCustomCommandList::Move(int CurIndex, int NewIndex)
 
- {
 
-   if (CurIndex != NewIndex)
 
-   {
 
-     FCommands->Move(CurIndex, NewIndex);
 
-     Modify();
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TCustomCommandList::Delete(int Index)
 
- {
 
-   DebugAssert((Index >= 0) && (Index < Count));
 
-   delete GetCommand(Index);
 
-   FCommands->Delete(Index);
 
-   Modify();
 
- }
 
- //---------------------------------------------------------------------------
 
- int __fastcall TCustomCommandList::GetCount() const
 
- {
 
-   return FCommands->Count;
 
- }
 
- //---------------------------------------------------------------------------
 
- const TCustomCommandType * __fastcall TCustomCommandList::GetConstCommand(int Index) const
 
- {
 
-   return static_cast<TCustomCommandType *>(FCommands->Items[Index]);
 
- }
 
- //---------------------------------------------------------------------------
 
- TCustomCommandType * __fastcall TCustomCommandList::GetCommand(int Index)
 
- {
 
-   return static_cast<TCustomCommandType *>(FCommands->Items[Index]);
 
- }
 
- //---------------------------------------------------------------------------
 
- bool __fastcall TCustomCommandList::Equals(const TCustomCommandList * Other) const
 
- {
 
-   bool Result = (Count == Other->Count);
 
-   for (int Index = 0; Result && (Index < Count); Index++)
 
-   {
 
-     Result = Commands[Index]->Equals(Other->Commands[Index]);
 
-   }
 
-   return Result;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TCustomCommandList::Assign(const TCustomCommandList * Other)
 
- {
 
-   Clear();
 
-   for (int Index = 0; Index < Other->Count; Index++)
 
-   {
 
-     Add(new TCustomCommandType(*Other->Commands[Index]));
 
-   }
 
-   // there should be comparison of with the assigned list, be we rely on caller
 
-   // to do it instead (TGUIConfiguration::SetCopyParamList)
 
-   Modify();
 
- }
 
- //---------------------------------------------------------------------------
 
- const TCustomCommandType * TCustomCommandList::Find(const UnicodeString Name) const
 
- {
 
-   for (int Index = 0; Index < FCommands->Count; Index++)
 
-   {
 
-     if (Commands[Index]->Name == Name)
 
-     {
 
-       return Commands[Index];
 
-     }
 
-   }
 
-   return NULL;
 
- }
 
- //---------------------------------------------------------------------------
 
- const TCustomCommandType * TCustomCommandList::Find(TShortCut ShortCut) const
 
- {
 
-   for (int Index = 0; Index < FCommands->Count; Index++)
 
-   {
 
-     if (Commands[Index]->ShortCut == ShortCut)
 
-     {
 
-       return Commands[Index];
 
-     }
 
-   }
 
-   return NULL;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TCustomCommandList::ShortCuts(TShortCuts & ShortCuts) const
 
- {
 
-   for (int Index = 0; Index < FCommands->Count; Index++)
 
-   {
 
-     const TCustomCommandType * Command = Commands[Index];
 
-     if (Command->ShortCut != 0)
 
-     {
 
-       ShortCuts.Add(Command->ShortCut);
 
-     }
 
-   }
 
- }
 
 
  |