win-desktop-utils 0.5.5

Windows desktop helpers for shell, shortcuts, app data, elevation, and single-instance Rust apps
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
fn main() -> Result<(), Box<dyn std::error::Error>> {
    let options = win_desktop_utils::SingleInstanceOptions::new("demo-app-options")
        .scope(win_desktop_utils::InstanceScope::CurrentSession);

    match options.acquire()? {
        Some(_guard) => {
            println!("first instance using options");
            println!("press Enter to exit");
            let mut s = String::new();
            std::io::stdin().read_line(&mut s)?;
        }
        None => {
            println!("already running");
        }
    }

    Ok(())
}