Skip to main content

open_url

Function open_url 

Source
pub fn open_url(url: &str) -> Result<()>
Expand description

Opens a URL with the user’s default browser or registered handler.

Surrounding whitespace is trimmed before the URL is passed to the Windows shell. URL validation is otherwise delegated to the Windows shell.

§Errors

Returns Error::InvalidInput if url is empty, whitespace only, or contains NUL bytes. Returns Error::WindowsApi if ShellExecuteW reports failure.

§Examples

win_desktop_utils::open_url("https://www.rust-lang.org")?;
Examples found in repository?
examples/open.rs (line 4)
1fn main() -> Result<(), win_desktop_utils::Error> {
2    win_desktop_utils::show_properties(r"C:\Windows\notepad.exe")?;
3    win_desktop_utils::open_containing_folder(r"C:\Windows\notepad.exe")?;
4    win_desktop_utils::open_url(" https://www.rust-lang.org ")?;
5    Ok(())
6}