Changed registry check to be only performed once on startup

This commit is contained in:
Erik Tönsfeldt 2021-09-14 15:16:39 +02:00
parent feedbe6ce4
commit c9c9615669
3 changed files with 20 additions and 9 deletions

View file

@ -319,5 +319,11 @@ public int HotkeyRepeatLimit
public List<Color> RecentColors = new List<Color>();
#endregion Color Picker Form
#region Formless
public bool UploadForbidden = false;
#endregion Formless
}
}

View file

@ -115,6 +115,7 @@ private static string HotkeysConfigFilePath
public static void LoadInitialSettings()
{
LoadApplicationConfig();
LoadUploadForbiddenRegistry();
Task.Run(() =>
{
@ -173,6 +174,18 @@ private static void Settings_SettingsSaveFailed(Exception e)
settingsSaveFailWarningCount++;
}
private static void LoadUploadForbiddenRegistry()
{
try
{
Settings.UploadForbidden = RegistryHelpers.CheckRegistry("SOFTWARE\\ShareX", "UploadForbidden", "true", Microsoft.Win32.RegistryHive.LocalMachine);
}
catch (Exception e)
{
DebugHelper.WriteException(e);
}
}
public static void LoadUploadersConfig(bool fallbackSupport = true)
{
UploadersConfig = UploadersConfig.Load(UploadersConfigFilePath, BackupFolder, fallbackSupport);

View file

@ -1797,15 +1797,7 @@ public static void ShowNotificationTip(string text, string title = "ShareX", int
public static bool IsUploadAllowed()
{
bool isDisabled = false;
try {
isDisabled = RegistryHelpers.CheckRegistry("SOFTWARE\\ShareX", "DisableUpload", "true", Microsoft.Win32.RegistryHive.LocalMachine);
}
catch(Exception e) {
DebugHelper.WriteException(e);
}
if (isDisabled)
if (Program.Settings.UploadForbidden)
{
MessageBox.Show(Resources.YourSystemAdminDisabledTheUploadFeature, "ShareX",
MessageBoxButtons.OK, MessageBoxIcon.Information);