Skip to content

Commit

Permalink
fix mica install, fix uninstall
Browse files Browse the repository at this point in the history
  • Loading branch information
MishaProductions committed Jun 12, 2024
1 parent cb23e43 commit 63f128c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 25 deletions.
31 changes: 23 additions & 8 deletions Rectify11Installer/Core/Backend/Installer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,30 @@ public bool Install(FrmWizard frm)
// extract files, delete if folder exists
frm.InstallerProgress = "Extracting files...";
Helper.SafeDirectoryDeletion(Path.Combine(Variables.r11Folder, "files"), false);
if (!Helper.SafeFileOperation(
Path.Combine(Variables.r11Folder, "files.7z"),
Properties.Resources.files,
Helper.OperationType.Write))
return false;
if (!Helper.SafeFileOperation(
Path.Combine(Variables.r11Folder, "files.7z"),
Properties.Resources.files,
Helper.OperationType.Write))
return false;

// extract the 7z
Helper.SvExtract("files.7z", "files");

if (InstallOptions.InstallThemes || InstallOptions.InstallExtras())
{
// Install/update r11cpl first to make RectifyUtil class work
try
{
Themes.InstallR11Cpl();
Logger.WriteLine("Installr11cpl() succeeded.");
}
catch (Exception ex)
{
Logger.Warn("Installr11cpl() failed", ex);
return false;
}
}

// theme
if (InstallOptions.InstallThemes)
{
Expand All @@ -96,7 +111,7 @@ public bool Install(FrmWizard frm)
}

// copy duires if any icons were patched or if themes was selected (required for r11cpl)
if (InstallOptions.iconsList.Count > 0 || InstallOptions.InstallThemes)
if (InstallOptions.iconsList.Count > 0 || InstallOptions.InstallThemes)
{
File.Copy(Path.Combine(Variables.r11Files, "duires.dll"), Path.Combine(Variables.sys32Folder, "duires.dll"), true);
}
Expand All @@ -106,7 +121,7 @@ public bool Install(FrmWizard frm)
frm.InstallerProgress = Rectify11Installer.Strings.Rectify11.creatingUninstaller;
Common.CreateUninstall();

InstallStatus.IsRectify11Installed = true;
InstallStatus.IsRectify11Installed = true;
Logger.WriteLine("══════════════════════════════════════════════");

// cleanup
Expand All @@ -122,7 +137,7 @@ private void InstallChangelogApp()
var key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
key?.SetValue("RectifyStart", Path.Combine(Variables.r11Folder, "RectifyStart.exe"), RegistryValueKind.String);
key.Close();
}
}
#endregion
}
}
27 changes: 11 additions & 16 deletions Rectify11Installer/Core/Backend/Themes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,7 @@ public static bool Install()
// extract the 7z
Helper.SvExtract("themes.7z", "themes");

// Install/update r11cpl first to make RectifyUtil class work
try
{
InstallR11Cpl();
Logger.WriteLine("Installr11cpl() succeeded.");
}
catch (Exception ex)
{
Logger.Warn("Installr11cpl() failed", ex);
return false;
}


if (!InstallThemes())
return false;
Expand Down Expand Up @@ -155,7 +145,14 @@ public static bool Uninstall()
}
catch { }

UninstallR11Cpl();
try
{
UninstallR11Cpl();
}
catch(Exception ex)
{
Logger.WriteLine("error while uninstalling r11cpl: ", ex);
}
Logger.WriteLine("Deleted Rectify11 Control Panel");

Process.Start(Path.Combine(Variables.sys32Folder, "reg.exe"), @" ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide /v PreferExternalManifest /t REG_DWORD /d 0 /f");
Expand Down Expand Up @@ -343,10 +340,8 @@ private static void InstallMfe()


// Enable MFE
bool bEnabled = InstallOptions.EnableMicaEffect;
bool bTabbed = InstallOptions.UseTabbedInsteadOfMica;
Console.WriteLine("Installing MFE: bEnabled: " + bEnabled + ",bTabbed: " + bTabbed);
RectifyThemeUtil.Utility.SetMicaForEveryoneEnabled(ref bEnabled, ref bTabbed);
Console.WriteLine("Installing MFE: bEnabled: " + InstallOptions.EnableMicaEffect + ",bTabbed: " + InstallOptions.UseTabbedInsteadOfMica);
RectifyThemeUtil.Utility.SetMicaForEveryoneEnabled(InstallOptions.EnableMicaEffect, InstallOptions.UseTabbedInsteadOfMica);
}

#region Internal
Expand Down
2 changes: 1 addition & 1 deletion Rectify11Installer/Win32/RectifyUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class CRectifyUtil
public interface IRectifyUtil
{
public nint GetMicaSettings(ref bool enabled, ref bool tabbed);
public nint SetMicaForEveryoneEnabled(ref bool enabled, ref bool tabbed);
public nint SetMicaForEveryoneEnabled(bool enabled, bool tabbed);
public nint GetCurrentMenuIndex(ref int index);
public nint SetCurrentMenuByIndex(int index);

Expand Down

0 comments on commit 63f128c

Please sign in to comment.