diff --git a/src/windows.rs b/src/windows.rs index 2bd22ef..2977c78 100644 --- a/src/windows.rs +++ b/src/windows.rs @@ -40,24 +40,34 @@ fn wrap_in_quotes>(path: T) -> OsString { } pub fn that_detached>(path: T) -> std::io::Result<()> { - detached(path, None::<&str>) -} + let path = wide(path); -pub fn with_detached>(path: T, app: impl Into) -> std::io::Result<()> { - detached(path, Some(app)) + unsafe { + ShellExecuteW( + 0, + ffi::OPEN, + path.as_ptr(), + ptr::null(), + ptr::null(), + ffi::SW_SHOW, + ) + } } -#[inline] -fn detached>(path: T, app: Option>) -> std::io::Result<()> { +pub fn with_detached>(path: T, app: impl Into) -> std::io::Result<()> { + let app = wide(app.into()); let path = wide(path); - let app = app.map(|a| wide(a.into())); - - let (app, args) = match app { - Some(app) => (app.as_ptr(), path.as_ptr()), - None => (path.as_ptr(), ptr::null()), - }; - unsafe { ShellExecuteW(0, ffi::OPEN, app, args, ptr::null(), ffi::SW_SHOW) } + unsafe { + ShellExecuteW( + 0, + ffi::OPEN, + app.as_ptr(), + path.as_ptr(), + ptr::null(), + ffi::SW_SHOW, + ) + } } /// Encodes as wide and adds a null character.