Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianEddy committed Nov 16, 2023
1 parent c3fc739 commit 4d93e5e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ edition = '2021'
"zbus" = "3.14.1"

[target.'cfg(target_os = "windows")'.dependencies.windows]
version = '0.51.0'
version = '0.52.0'
features = [
'Win32_Foundation',
'Win32_Security',
Expand All @@ -30,5 +30,4 @@ features = [
'Win32_System_Shutdown',
'Win32_System_Power',
'Win32_System_SystemServices',
'Win32_UI_WindowsAndMessaging',
]
13 changes: 6 additions & 7 deletions src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ use windows::{
Shutdown::{
ExitWindowsEx, InitiateSystemShutdownW, EWX_LOGOFF, EWX_REBOOT, EWX_SHUTDOWN,
EXIT_WINDOWS_FLAGS, SHTDN_REASON_FLAG_PLANNED, SHTDN_REASON_MAJOR_OPERATINGSYSTEM,
SHTDN_REASON_MINOR_UPGRADE,
SHTDN_REASON_MINOR_UPGRADE, EWX_FORCE, EWX_FORCEIFHUNG
},
Threading::{GetCurrentProcess, OpenProcessToken},
},
UI::WindowsAndMessaging::{EWX_FORCE, EWX_FORCEIFHUNG},
}
},
};

Expand Down Expand Up @@ -66,7 +65,7 @@ fn exit_windows(flag: u32) -> ShutdownResult {
unsafe {
request_privileges()?;
if !ExitWindowsEx(
EXIT_WINDOWS_FLAGS(flag | EWX_FORCEIFHUNG),
EXIT_WINDOWS_FLAGS(flag | EWX_FORCEIFHUNG.0),
SHTDN_REASON_MAJOR_OPERATINGSYSTEM
| SHTDN_REASON_MINOR_UPGRADE
| SHTDN_REASON_FLAG_PLANNED,
Expand Down Expand Up @@ -133,7 +132,7 @@ pub fn shutdown() -> ShutdownResult {

/// Windows specific function to shut down the machine instantly without confirmations using the `ExitWindowsEx()` from `winuser` API.
pub fn force_shutdown() -> ShutdownResult {
exit_windows(EWX_SHUTDOWN.0 | EWX_FORCE)
exit_windows(EWX_SHUTDOWN.0 | EWX_FORCE.0)
}

/// Windows specific function to reboot the machine using the `ExitWindowsEx()` from `winuser` API.
Expand All @@ -143,7 +142,7 @@ pub fn reboot() -> ShutdownResult {

/// Windows specific function to reboot the machine instantly without confirmations using the `ExitWindowsEx()` from `winuser` API.
pub fn force_reboot() -> ShutdownResult {
exit_windows(EWX_REBOOT.0 | EWX_FORCE)
exit_windows(EWX_REBOOT.0 | EWX_FORCE.0)
}

/// Windows specific function to log out the user using the `ExitWindowsEx()` from `winuser` API.
Expand All @@ -153,7 +152,7 @@ pub fn logout() -> ShutdownResult {

/// Windows specific function to log out the user instantly without confirmations using the `ExitWindowsEx()` from `winuser` API.
pub fn force_logout() -> ShutdownResult {
exit_windows(EWX_LOGOFF.0 | EWX_FORCE)
exit_windows(EWX_LOGOFF.0 | EWX_FORCE.0)
}

/// Windows specific function to put the machine to sleep using `SetSuspendState()` API call.
Expand Down

0 comments on commit 4d93e5e

Please sign in to comment.