Browse Source

Issue 2245 – Window Store installation on Windows 11 was incorrectly using INI file for configuration storage by default

https://winscp.net/tracker/2245

On Windows 11 (unless WinSCP was run as Administrator the first time) the default packaged HKLM registry key was not loaded, causing WinSCP to default to INI file. On Windows 10 the problem does not exist.
I never liked using cryptic binary Registry.dat file for distributing default settings anyway. This is good opportunity to get rid of it and instead have the application use the intended defaults automatically on UWP

Source commit: 16adc7b5d73cdcab5160cda99b62de5a99ff7229
Martin Prikryl 1 year ago
parent
commit
1ab3de7c59

+ 4 - 0
source/WinSCP.cpp

@@ -35,6 +35,10 @@ WINAPI wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int)
       OnAppLog = AppLogImpl;
     }
     AppLog(L"Starting...");
+    if (Params->FindSwitch(L"IsUWP"))
+    {
+      EnableUWPTestMode();
+    }
 
     AddStartupSequence(L"M");
     AppLogFmt(L"Process: %d", (GetCurrentProcessId()));

+ 6 - 0
source/core/Common.cpp

@@ -3116,6 +3116,12 @@ bool __fastcall IsWine()
 int GIsUWP = -1;
 UnicodeString GPackageName;
 //---------------------------------------------------------------------------
+void EnableUWPTestMode()
+{
+  GIsUWP = 1;
+  AppLog(L"UWP test mode");
+}
+//---------------------------------------------------------------------------
 static void NeedUWPData()
 {
   if (GIsUWP < 0)

+ 1 - 0
source/core/Common.h

@@ -150,6 +150,7 @@ bool __fastcall IsWin10();
 bool __fastcall IsWin10Build(unsigned int BuildNumber);
 bool IsWin11();
 bool __fastcall IsWine();
+void EnableUWPTestMode();
 bool __fastcall IsUWP();
 UnicodeString GetPackageName();
 bool IsOfficialPackage();

+ 2 - 1
source/core/Configuration.cpp

@@ -176,7 +176,7 @@ __fastcall TConfiguration::TConfiguration()
   FForceSave = false;
   FApplicationInfo = NULL;
   FUsage = new TUsage(this);
-  FDefaultCollectUsage = false;
+  FDefaultCollectUsage = IsUWP();
   FScripting = false;
   FSshHostCAList.reset(new TSshHostCAList());
 
@@ -1622,6 +1622,7 @@ TStorage __fastcall TConfiguration::GetStorage()
   TGuard Guard(FCriticalSection);
   if (FStorage == stDetect)
   {
+    DebugFail(); // This is never called, as the detection is completelly overriden by TWinConfiguration
     if (FileExists(ApiPath(IniFileStorageNameForReading)))
     {
       FStorage = stIniFile;

+ 2 - 1
source/windows/WinConfiguration.cpp

@@ -877,7 +877,8 @@ bool TWinConfiguration::DetectStorage(bool SafeOnly)
   }
   else
   {
-    if (DetectRegistryStorage(HKEY_CURRENT_USER) ||
+    if (IsUWP() ||
+        DetectRegistryStorage(HKEY_CURRENT_USER) ||
         DetectRegistryStorage(HKEY_LOCAL_MACHINE))
     {
       FStorage = stRegistry;