Skip to content

Commit a95a288

Browse files
committed
Switch to windows-sys
windows-sys exposes the Windows API from machine-generated code based on Windows metadata. The crate is provided by Microsoft and has generally faster compile time than winapi.
1 parent ee25446 commit a95a288

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ doc = false
1717
name = "open"
1818

1919
[target.'cfg(windows)'.dependencies]
20-
winapi = { version = "0.3", features = ["shellapi"] }
20+
windows-sys = { version = "0.36", features = ["Win32_UI_Shell", "Win32_Foundation"] }
2121

2222
[target.'cfg(all(unix, not(macos)))'.dependencies]
2323
pathdiff = "0.2.0"

src/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ impl IntoResult<Result> for io::Result<Output> {
156156
}
157157

158158
#[cfg(windows)]
159-
impl IntoResult<Result> for winapi::ctypes::c_int {
159+
impl IntoResult<Result> for std::os::raw::c_int {
160160
fn into_result(self) -> Result {
161161
match self {
162162
i if i > 32 => Ok(()),
@@ -214,8 +214,8 @@ impl CommandExt for Command {
214214
mod windows {
215215
use std::{ffi::OsStr, io, os::windows::ffi::OsStrExt, ptr};
216216

217-
use winapi::ctypes::c_int;
218-
use winapi::um::shellapi::ShellExecuteW;
217+
use std::os::raw::c_int;
218+
use windows_sys::Win32::UI::Shell::ShellExecuteW;
219219

220220
use crate::{IntoResult, Result};
221221

@@ -238,7 +238,7 @@ mod windows {
238238
let operation: Vec<u16> = OsStr::new("open\0").encode_wide().collect();
239239
let result = unsafe {
240240
ShellExecuteW(
241-
ptr::null_mut(),
241+
0,
242242
operation.as_ptr(),
243243
path.as_ptr(),
244244
ptr::null(),
@@ -259,7 +259,7 @@ mod windows {
259259
.collect();
260260
let result = unsafe {
261261
ShellExecuteW(
262-
ptr::null_mut(),
262+
0,
263263
operation.as_ptr(),
264264
app_name.as_ptr(),
265265
path.as_ptr(),

0 commit comments

Comments
 (0)