fix: update Windows API calls for windows crate v0.52

This commit is contained in:
Nathan Flurry 2026-02-06 03:50:50 -08:00
parent 60e1ce7e2d
commit 96ae6bed96

View file

@ -122,18 +122,18 @@ pub fn is_process_running(pid: u32) -> bool {
#[cfg(windows)] #[cfg(windows)]
pub fn is_process_running(pid: u32) -> bool { pub fn is_process_running(pid: u32) -> bool {
use windows::Win32::Foundation::{CloseHandle, HANDLE}; use windows::Win32::Foundation::CloseHandle;
use windows::Win32::System::Threading::{ use windows::Win32::System::Threading::{
GetExitCodeProcess, OpenProcess, PROCESS_QUERY_LIMITED_INFORMATION, GetExitCodeProcess, OpenProcess, PROCESS_QUERY_LIMITED_INFORMATION,
}; };
unsafe { unsafe {
let handle = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, false, pid); let handle = match OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, false, pid) {
if handle.is_invalid() { Ok(h) => h,
return false; Err(_) => return false,
} };
let mut exit_code = 0u32; let mut exit_code = 0u32;
let ok = GetExitCodeProcess(handle, &mut exit_code).as_bool(); let ok = GetExitCodeProcess(handle, &mut exit_code).is_ok();
let _ = CloseHandle(handle); let _ = CloseHandle(handle);
ok && exit_code == 259 ok && exit_code == 259
} }