Skip to content

Commit 4cf6130

Browse files
authored
Merge pull request #70 from sn99/master
Migrate from winapi to windows-rs by microsoft
2 parents bba9a16 + 3d880ab commit 4cf6130

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ git2 = "0.14.0"
4545
nix = "0.20.0"
4646

4747
[target.'cfg(windows)'.dependencies]
48-
winapi = "0.3"
48+
windows-sys = {version = "0.36.1", features = ["Win32_Foundation", "Win32_System_Threading"]}
4949

5050
[dev-dependencies]
5151
env_logger = "0.8"

src/native/windows.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@ use crate::cmd::KillFailedError;
33
use failure::{bail, Error};
44
use std::fs::File;
55
use std::path::Path;
6-
use winapi::um::handleapi::CloseHandle;
7-
use winapi::um::processthreadsapi::{OpenProcess, TerminateProcess};
8-
use winapi::um::winnt::PROCESS_TERMINATE;
6+
use windows_sys::Win32::Foundation::CloseHandle;
7+
use windows_sys::Win32::System::Threading::{OpenProcess, TerminateProcess, PROCESS_TERMINATE};
98

109
pub(crate) fn kill_process(id: u32) -> Result<(), KillFailedError> {
1110
let error = Err(KillFailedError { pid: id });
1211

1312
unsafe {
1413
let handle = OpenProcess(PROCESS_TERMINATE, 0, id);
15-
if handle.is_null() {
14+
if handle == 0 || handle == -1 {
1615
return error;
1716
}
1817
if TerminateProcess(handle, 101) == 0 {

0 commit comments

Comments
 (0)