diff --git a/Cargo.toml b/Cargo.toml index 022cc11d7..a7108e2c1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -181,7 +181,7 @@ futures-util = { version = "0.3.28", default-features = false, features = ["std" rustls = { version = "0.23", default-features = false, features = ["ring"] } [target.'cfg(windows)'.dependencies] -winreg = "0.52.0" +windows-registry = "0.2" [target.'cfg(target_os = "macos")'.dependencies] system-configuration = { version = "0.5.1", optional = true } diff --git a/src/proxy.rs b/src/proxy.rs index 98708c775..5be207a8a 100644 --- a/src/proxy.rs +++ b/src/proxy.rs @@ -29,10 +29,6 @@ use system_configuration::{ sys::schema_definitions::kSCPropNetProxiesHTTPSPort, sys::schema_definitions::kSCPropNetProxiesHTTPSProxy, }; -#[cfg(target_os = "windows")] -use winreg::enums::HKEY_CURRENT_USER; -#[cfg(target_os = "windows")] -use winreg::RegKey; /// Configuration of a proxy that a `Client` should pass requests to. /// @@ -937,12 +933,11 @@ fn is_cgi() -> bool { #[cfg(target_os = "windows")] fn get_from_platform_impl() -> Result, Box> { - let hkcu = RegKey::predef(HKEY_CURRENT_USER); - let internet_setting: RegKey = - hkcu.open_subkey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings")?; + let internet_setting = windows_registry::CURRENT_USER + .open("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings")?; // ensure the proxy is enable, if the value doesn't exist, an error will returned. - let proxy_enable: u32 = internet_setting.get_value("ProxyEnable")?; - let proxy_server: String = internet_setting.get_value("ProxyServer")?; + let proxy_enable = internet_setting.get_u32("ProxyEnable")?; + let proxy_server = internet_setting.get_string("ProxyServer")?; Ok((proxy_enable == 1).then_some(proxy_server)) }