wezterm-open-url: Replace winapi with windows-sys (#8101)

This commit is contained in:
xtqqczze 2026-08-26 10:36:37 +01:00 committed by GitHub
parent 6fecdf5ae1
commit 70c036a236
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 5 deletions

2
Cargo.lock generated
View File

@ -7260,7 +7260,7 @@ dependencies = [
name = "wezterm-open-url"
version = "0.1.0"
dependencies = [
"winapi",
"windows-sys 0.61.2",
]
[[package]]

View File

@ -6,5 +6,8 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
winapi = {workspace=true, features=["shellapi"]}
[target."cfg(windows)".dependencies]
windows-sys = { workspace = true, features = [
"Win32_UI_Shell",
"Win32_UI_WindowsAndMessaging",
] }

View File

@ -57,7 +57,9 @@ pub fn open_with(url: &str, app: &str) {
#[cfg(windows)]
fn shell_execute(url: String, with: Option<String>) {
use std::os::windows::ffi::OsStrExt;
use winapi::um::shellapi::ShellExecuteW;
use windows_sys::Win32::UI::Shell::ShellExecuteW;
use windows_sys::Win32::UI::WindowsAndMessaging::SW_SHOW;
/// Convert a rust string to a windows wide string
fn wide_string(s: &str) -> Vec<u16> {
std::ffi::OsStr::new(s)
@ -83,7 +85,7 @@ fn shell_execute(url: String, with: Option<String>) {
app,
path,
std::ptr::null(),
winapi::um::winuser::SW_SHOW,
SW_SHOW,
);
}
});