gentoo90 / winreg-rs

Rust bindings to MS Windows Registry API
MIT License
165 stars 36 forks source link

Don't set the internet Settings correctly #50

Open irocn opened 1 year ago

irocn commented 1 year ago

Hello,

I want to set windows proxy as "socks=127.0.0.1" and port 1080, but it will be "http://socks=127.0.0.1". How to fix it?

    let (key, _) = RegKey::predef(HKEY_CURRENT_USER).create_subkey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings")?;
    if isOpen{
        key.set_value("ProxyEnable", &1u32)?;
        key.set_value("ProxyServer", &format!("{}:{}", "socks=127.0.0.1", 1080))?;
        key.set_value("ProxyOverride", &"<local>")?;
    }else{
        key.set_value("ProxyEnable", &0u32)?;
    }
gentoo90 commented 1 year ago

I don't understand the question. Your code does exactly what it should and sets the proxy settings like this: изображение

"http://socks=127.0.0.1/"

is this what appears in the address string of the browser?

irocn commented 1 year ago

yes, but in the socks address box is "http://socks=127.0.0.1", the prefix "http://" will be added auto. my os is windows 11.

btw, "http://socks=127.0.0.1" don't work, "socks=127.0.0.1" work well.