mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-03 02:36:50 +13:00
Add try catch to startup manager codes
This commit is contained in:
parent
89820bad63
commit
295749d711
1 changed files with 23 additions and 8 deletions
|
@ -256,15 +256,23 @@ private void UpdateStartWithWindows()
|
|||
cbStartWithWindows.Text = Resources.ApplicationSettingsForm_cbStartWithWindows_Text;
|
||||
cbStartWithWindows.Enabled = false;
|
||||
|
||||
StartupTaskState state = StartupManagerFactory.StartupManager.State;
|
||||
cbStartWithWindows.Checked = state == StartupTaskState.Enabled;
|
||||
if (state == StartupTaskState.DisabledByUser)
|
||||
try
|
||||
{
|
||||
cbStartWithWindows.Text = Resources.ApplicationSettingsForm_cbStartWithWindows_DisabledByUser_Text;
|
||||
StartupTaskState state = StartupManagerFactory.StartupManager.State;
|
||||
cbStartWithWindows.Checked = state == StartupTaskState.Enabled;
|
||||
|
||||
if (state == StartupTaskState.DisabledByUser)
|
||||
{
|
||||
cbStartWithWindows.Text = Resources.ApplicationSettingsForm_cbStartWithWindows_DisabledByUser_Text;
|
||||
}
|
||||
else
|
||||
{
|
||||
cbStartWithWindows.Enabled = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (Exception e)
|
||||
{
|
||||
cbStartWithWindows.Enabled = true;
|
||||
e.ShowError();
|
||||
}
|
||||
|
||||
ready = true;
|
||||
|
@ -397,8 +405,15 @@ private void cbStartWithWindows_CheckedChanged(object sender, EventArgs e)
|
|||
{
|
||||
if (ready)
|
||||
{
|
||||
StartupManagerFactory.StartupManager.State = cbStartWithWindows.Checked ? StartupTaskState.Enabled : StartupTaskState.Disabled;
|
||||
UpdateStartWithWindows();
|
||||
try
|
||||
{
|
||||
StartupManagerFactory.StartupManager.State = cbStartWithWindows.Checked ? StartupTaskState.Enabled : StartupTaskState.Disabled;
|
||||
UpdateStartWithWindows();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.ShowError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue