Skip to content

Portable Tool for an Ideal Windows Setup

-refactoring & added rename of the general registrykey has been added

Greedeksa2b326fa5d42
diff --git a/.Source/GTweak/Utilities/Helpers/INIManager.cs b/.Source/GTweak/Utilities/Helpers/INIManager.cs
index f7d3e28a..d6e32d90 100644
--- a/.Source/GTweak/Utilities/Helpers/INIManager.cs
+++ b/.Source/GTweak/Utilities/Helpers/INIManager.cs
@@ -74,9 +74,9 @@ namespace GTweak.Utilities.Helpers
foreach (string data in temp)
{
- int equalsIndex = data.IndexOf("=", StringComparison.InvariantCulture); if (equalsIndex > 0)
+ int equalsIndex = data.IndexOf("=", StringComparison.InvariantCulture);
+ if (equalsIndex > 0)
result.Add(isGetKey ? data.Substring(0, equalsIndex) : data.Substring(equalsIndex + 1));
-
}
return result;
}
diff --git a/.Source/GTweak/Utilities/Helpers/RegistryHelp.cs b/.Source/GTweak/Utilities/Helpers/RegistryHelp.cs
index de70dfe7..f0a7a72a 100644
--- a/.Source/GTweak/Utilities/Helpers/RegistryHelp.cs
+++ b/.Source/GTweak/Utilities/Helpers/RegistryHelp.cs
@@ -7,6 +7,18 @@ namespace GTweak.Utilities.Helpers
{
internal sealed class RegistryHelp
{
+ private static string GeneralRegistry(RegistryKey registrykey)
+ {
+ return registrykey.Name switch
+ {
+ "HKEY_LOCAL_MACHINE" => $@"MACHINE\",
+ "HKEY_CLASSES_ROOT" => $@"CLASSES_ROOT\",
+ "HKEY_CURRENT_USER" => $@"CURRENT_USER\",
+ "HKEY_USERS" => $@"USERS\",
+ _ => $@"CURRENT_CONFIG\",
+ };
+ }
+
internal static void DeleteValue(RegistryKey registrykey, string subkey, string value, bool isTakingOwner = false)
{
Task.Run(async delegate
@@ -16,7 +28,7 @@ namespace GTweak.Utilities.Helpers
{
if (isTakingOwner)
{
- TakingOwnership.GrantAdministratorsAccess($@"MACHINE\{subkey}", TakingOwnership.SE_OBJECT_TYPE.SE_REGISTRY_KEY);
+ TakingOwnership.GrantAdministratorsAccess($"{GeneralRegistry(registrykey)}{subkey}", TakingOwnership.SE_OBJECT_TYPE.SE_REGISTRY_KEY);
await Task.Delay(200);
}
@@ -34,7 +46,7 @@ namespace GTweak.Utilities.Helpers
{
if (isTakingOwner)
{
- TakingOwnership.GrantAdministratorsAccess($@"MACHINE\{subkey}", TakingOwnership.SE_OBJECT_TYPE.SE_REGISTRY_KEY);
+ TakingOwnership.GrantAdministratorsAccess($"{GeneralRegistry(registrykey)}{subkey}", TakingOwnership.SE_OBJECT_TYPE.SE_REGISTRY_KEY);
await Task.Delay(200);
}
@@ -98,6 +110,5 @@ namespace GTweak.Utilities.Helpers
return string.Concat((byte[])Registry.GetValue(subkey, valueName, null) ?? Array.Empty<byte>()) != expectedValue;
}
-
}
}
diff --git a/.Source/GTweak/Utilities/Helpers/TakingOwnership.cs b/.Source/GTweak/Utilities/Helpers/TakingOwnership.cs
index 7be20da7..ba18e294 100644
--- a/.Source/GTweak/Utilities/Helpers/TakingOwnership.cs
+++ b/.Source/GTweak/Utilities/Helpers/TakingOwnership.cs
@@ -15,7 +15,7 @@ namespace GTweak.Utilities.Helpers
[StructLayout(LayoutKind.Sequential)]
private struct TRUSTEE
{
- public System.IntPtr pMultipleTrustee;
+ public IntPtr pMultipleTrustee;
public MULTIPLE_TRUSTEE_OPERATION MultipleTrusteeOperation;
public TRUSTEE_FORM TrusteeForm;
public TRUSTEE_TYPE TrusteeType;