Skip to content

Commit

Permalink
Add admin privilege checking
Browse files Browse the repository at this point in the history
  • Loading branch information
fahminlb33 committed Jun 11, 2020
1 parent 1a3a3c4 commit 1fe6a8a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/KFmaintenance/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/KFmaintenance/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,7 @@
<data name="KFmaintenance" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\KFmaintenance.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="NotElevatedMessage" xml:space="preserve">
<value>Jalankan aplikasi sebagai Administrator terlebih dahulu.</value>
</data>
</root>
8 changes: 8 additions & 0 deletions src/KFmaintenance/Views/StartupForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public partial class StartupForm : Form
private readonly ISystemInfoService _infoService = Program.Container.Resolve<ISystemInfoService>();
private readonly IRemoteShutdownServer _remoteService = Program.Container.Resolve<IRemoteShutdownServer>();
private readonly ISystemTweaker _systemTweaker = Program.Container.Resolve<ISystemTweaker>();
private readonly IProcessManager _processManager = Program.Container.Resolve<IProcessManager>();
private readonly IPathManager _pathManager = Program.Container.Resolve<IPathManager>();
private readonly IFormService _formService = Program.Container.Resolve<IFormService>();
private DateTime _lastShutdownRequest;
Expand Down Expand Up @@ -146,6 +147,13 @@ private void cmdSaveSettings_Click(object sender, EventArgs e)

private void cmdSaveRegistry_Click(object sender, EventArgs e)
{
if (!_processManager.IsProcessElevated())
{
MessageBox.Show(Resources.NotElevatedMessage, Resources.AppName, MessageBoxButtons.OK,
MessageBoxIcon.Exclamation);
return;
}

using (var frm = Program.Container.Resolve<AuthForm>())
{
var result = frm.ShowDialog();
Expand Down

0 comments on commit 1fe6a8a

Please sign in to comment.