You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Plugins/Flow.Launcher.Plugin.Sys/Main.cs
+67-23Lines changed: 67 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -2,13 +2,15 @@
2
2
using System.Collections.Generic;
3
3
using System.Diagnostics;
4
4
using System.IO;
5
+
using System.Runtime.InteropServices;
5
6
using System.Windows;
6
7
using Flow.Launcher.Infrastructure;
7
8
using Flow.Launcher.Infrastructure.Logger;
8
9
using Flow.Launcher.Infrastructure.UserSettings;
9
10
using Flow.Launcher.Plugin.SharedCommands;
10
11
using Windows.Win32;
11
12
using Windows.Win32.Foundation;
13
+
using Windows.Win32.Security;
12
14
using Windows.Win32.System.Shutdown;
13
15
using Application = System.Windows.Application;
14
16
using Control = System.Windows.Controls.Control;
@@ -20,6 +22,10 @@ public class Main : IPlugin, ISettingProvider, IPluginI18n
20
22
private PluginInitContext context;
21
23
private Dictionary<string, string> KeywordTitleMappings = new Dictionary<string, string>();
22
24
25
+
// SHTDN_REASON_MAJOR_OTHER indicates a generic shutdown reason that isn't categorized under hardware failure, software updates, or other predefined reasons.
26
+
// SHTDN_REASON_FLAG_PLANNED marks the shutdown as planned rather than an unexpected shutdown or failure
if (!PInvoke.OpenProcessToken(Process.GetCurrentProcess().SafeHandle, TOKEN_ACCESS_MASK.TOKEN_ADJUST_PRIVILEGES | TOKEN_ACCESS_MASK.TOKEN_QUERY, out var tokenHandle))
114
+
{
115
+
return false;
116
+
}
117
+
118
+
if (!PInvoke.LookupPrivilegeValue(null, PInvoke.SE_SHUTDOWN_NAME, out var luid))
0 commit comments