Skip to content

Commit e93699b

Browse files
committed
Add shutdown reason
1 parent ffa3038 commit e93699b

File tree

1 file changed

+11
-4
lines changed
  • Plugins/Flow.Launcher.Plugin.Sys

1 file changed

+11
-4
lines changed

Plugins/Flow.Launcher.Plugin.Sys/Main.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,12 @@ private List<Result> Commands()
121121
context.API.GetTranslation("flowlauncher_plugin_sys_shutdown_computer"),
122122
MessageBoxButton.YesNo, MessageBoxImage.Warning);
123123

124+
// SHTDN_REASON_MAJOR_OTHER indicates a generic shutdown reason that isn't categorized under hardware failure,
125+
// software updates, or other predefined reasons.
126+
// SHTDN_REASON_FLAG_PLANNED marks the shutdown as planned rather than an unexpected shutdown or failure
124127
if (result == MessageBoxResult.Yes)
125-
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_SHUTDOWN | EXIT_WINDOWS_FLAGS.EWX_POWEROFF, SHUTDOWN_REASON.SHTDN_REASON_NONE);
128+
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_SHUTDOWN | EXIT_WINDOWS_FLAGS.EWX_POWEROFF,
129+
SHUTDOWN_REASON.SHTDN_REASON_MAJOR_OTHER | SHUTDOWN_REASON.SHTDN_REASON_FLAG_PLANNED);
126130

127131
return true;
128132
}
@@ -141,7 +145,8 @@ private List<Result> Commands()
141145
MessageBoxButton.YesNo, MessageBoxImage.Warning);
142146

143147
if (result == MessageBoxResult.Yes)
144-
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_REBOOT, SHUTDOWN_REASON.SHTDN_REASON_NONE);
148+
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_REBOOT,
149+
SHUTDOWN_REASON.SHTDN_REASON_MAJOR_OTHER | SHUTDOWN_REASON.SHTDN_REASON_FLAG_PLANNED);
145150

146151
return true;
147152
}
@@ -160,7 +165,8 @@ private List<Result> Commands()
160165
MessageBoxButton.YesNo, MessageBoxImage.Warning);
161166

162167
if (result == MessageBoxResult.Yes)
163-
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_REBOOT | EXIT_WINDOWS_FLAGS.EWX_BOOTOPTIONS, SHUTDOWN_REASON.SHTDN_REASON_NONE);
168+
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_REBOOT | EXIT_WINDOWS_FLAGS.EWX_BOOTOPTIONS,
169+
SHUTDOWN_REASON.SHTDN_REASON_MAJOR_OTHER | SHUTDOWN_REASON.SHTDN_REASON_FLAG_PLANNED);
164170

165171
return true;
166172
}
@@ -179,7 +185,8 @@ private List<Result> Commands()
179185
MessageBoxButton.YesNo, MessageBoxImage.Warning);
180186

181187
if (result == MessageBoxResult.Yes)
182-
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_LOGOFF, SHUTDOWN_REASON.SHTDN_REASON_NONE);
188+
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_LOGOFF,
189+
SHUTDOWN_REASON.SHTDN_REASON_MAJOR_OTHER | SHUTDOWN_REASON.SHTDN_REASON_FLAG_PLANNED);
183190

184191
return true;
185192
}

0 commit comments

Comments
 (0)