diff --git a/Cargo.lock b/Cargo.lock index 9456324fd..fb1d9ce55 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1991,8 +1991,7 @@ dependencies = [ "term_size 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index ffeb01ef8..5103c2b2b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,6 @@ app_dirs = "1.2.1" futures = "0.1" futures-cpupool = "0.1" fdlimit = "0.1" -ws2_32-sys = "0.2" ctrlc = { git = "https://github.com/paritytech/rust-ctrlc.git" } jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.11" } ethcore = { path = "ethcore" } @@ -86,7 +85,7 @@ tempdir = "0.3" fake-fetch = { path = "util/fake-fetch" } [target.'cfg(windows)'.dependencies] -winapi = "0.2" +winapi = { version = "0.3.4", features = ["winsock2", "winuser", "shellapi"] } [target.'cfg(not(windows))'.dependencies] daemonize = { git = "https://github.com/paritytech/daemonize" } diff --git a/parity/main.rs b/parity/main.rs index 4908f38d9..0b7c31d95 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -95,7 +95,6 @@ extern crate parity_dapps; #[macro_use] extern crate pretty_assertions; -#[cfg(windows)] extern crate ws2_32; #[cfg(windows)] extern crate winapi; #[cfg(test)] @@ -238,7 +237,7 @@ fn global_cleanup() { // The loop is required because of internal refernce counter for winsock dll. We don't know how many crates we use do // initialize it. There's at least 2 now. for _ in 0.. 10 { - unsafe { ::ws2_32::WSACleanup(); } + unsafe { ::winapi::um::winsock2::WSACleanup(); } } } @@ -250,8 +249,8 @@ fn global_init() { // When restarting in the same process this reinits windows sockets. unsafe { const WS_VERSION: u16 = 0x202; - let mut wsdata: ::winapi::winsock2::WSADATA = ::std::mem::zeroed(); - ::ws2_32::WSAStartup(WS_VERSION, &mut wsdata); + let mut wsdata: ::winapi::um::winsock2::WSADATA = ::std::mem::zeroed(); + ::winapi::um::winsock2::WSAStartup(WS_VERSION, &mut wsdata); } } diff --git a/parity/url.rs b/parity/url.rs index fd64e46ec..9b8959f01 100644 --- a/parity/url.rs +++ b/parity/url.rs @@ -16,34 +16,19 @@ //! Cross-platform open url in default browser -#[cfg(windows)] -mod shell { - extern crate winapi; - - use self::winapi::*; - extern "system" { - pub fn ShellExecuteA( - hwnd: HWND, lpOperation: LPCSTR, lpFile: LPCSTR, lpParameters: LPCSTR, lpDirectory: LPCSTR, - nShowCmd: c_int - ) -> HINSTANCE; - } - - pub use self::winapi::SW_SHOWNORMAL as Normal; -} - #[cfg(windows)] pub fn open(url: &str) { use std::ffi::CString; use std::ptr; + use winapi::um::shellapi::ShellExecuteA; + use winapi::um::winuser::SW_SHOWNORMAL as Normal; - unsafe { - shell::ShellExecuteA(ptr::null_mut(), - CString::new("open").unwrap().as_ptr(), - CString::new(url.to_owned().replace("\n", "%0A")).unwrap().as_ptr(), - ptr::null(), - ptr::null(), - shell::Normal); - } + ShellExecuteA(ptr::null_mut(), + CString::new("open").unwrap().as_ptr(), + CString::new(url.to_owned().replace("\n", "%0A")).unwrap().as_ptr(), + ptr::null(), + ptr::null(), + Normal); } #[cfg(any(target_os="macos", target_os="freebsd"))]