Crates.io | reg-watcher |
lib.rs | reg-watcher |
version | 0.1.1 |
source | src |
created_at | 2018-07-22 17:09:11.872439 |
updated_at | 2019-08-30 13:29:23.628391 |
description | A rust library for single instance application. |
homepage | |
repository | https://github.com/WLBF/reg-watcher |
max_upload_size | |
id | 75524 |
size | 36,494 |
Rust binding to MS Windows RegNotifyChangeKeyValue
API.
[dependencies]
reg-watcher = "0.1"
extern crate reg_watcher;
extern crate winreg;
use winreg::{
RegKey,
enums::*,
};
use reg_watcher::*;
fn main() {
let hklm = RegKey::predef(HKEY_LOCAL_MACHINE);
let reg_key = hklm.open_subkey(r#"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"#).unwrap();
let res = watch(®_key, filter::REG_LEGAL_CHANGE_FILTER, true, Timeout::Milli(60 * 1000)).unwrap();
println!("{:?}", res);
}
extern crate reg_watcher;
extern crate winreg;
use std::{
time::Duration,
sync::mpsc::channel,
};
use winreg::{
RegKey,
enums::*,
};
use reg_watcher::*;
fn main() {
let hklm = RegKey::predef(HKEY_LOCAL_MACHINE);
let reg_key = hklm.open_subkey(r#"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"#).unwrap();
let mut w = Watcher::new(reg_key, filter::REG_LEGAL_CHANGE_FILTER, true, Duration::from_secs(1));
let (sender, receiver) = channel();
let _ = w.watch_async(sender);
loop {
let res = receiver.recv().unwrap();
println!("{:?}", res);
}
}
extern crate futures;
extern crate reg_watcher;
extern crate winreg;
extern crate tokio;
use futures::prelude::*;
use std::{
time::Duration,
};
use winreg::{
RegKey,
enums::*,
};
use reg_watcher::*;
fn main() {
let hklm = RegKey::predef(HKEY_LOCAL_MACHINE);
let reg_key = hklm.open_subkey(r#"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"#).unwrap();
let w = Watcher::new(reg_key, filter::REG_LEGAL_CHANGE_FILTER, true, Duration::from_secs(1));
let fut = w.for_each(|_| {
println!("notify");
Ok(())
}).map_err(|err| {
println!("accept error = {:?}", err);
});
tokio::run(fut);
}