WMI crate for rust
Clone or download
Latest commit a14b340 Jan 29, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Move code around, run cargo fmt Jan 29, 2019
.gitignore Initial commit Dec 25, 2018
Cargo.toml Keywords Jan 29, 2019
LICENSE-APACHE Added licenses and readme Dec 25, 2018
LICENSE-MIT Added licenses and readme Dec 25, 2018
README.md Update readme Jan 29, 2019

README.md

wmi

Documentation

WMI crate for rust. Currently in alpha 🚧.

Examples

Queries can be deserialized info a free-form HashMap or a struct:

use std::collections::HashMap;
use serde::Deserialize;

use wmi::{from_wbem_class_obj, COMLibrary, Variant, WMIConnection, WMIDateTime};

let com_con = COMLibrary::new().unwrap();
let wmi_con = WMIConnection::new(com_con.into()).unwrap();

let results: Vec<HashMap<String, Variant>> = wmi_con.raw_query("SELECT * FROM Win32_OperatingSystem").unwrap();

for os in results {
    println!("{:#?}", os);
}

#[derive(Deserialize, Debug)]
struct Win32_OperatingSystem {
    Caption: String,
    Name: String,
    CurrentTimeZone: i16,
    Debug: bool,
    EncryptionLevel: u32,
    ForegroundApplicationBoost: u8,
    LastBootUpTime: WMIDateTime,
}

let results: Vec<Win32_OperatingSystem> = wmi_con.query().unwrap();

for os in results {
    println!("{:#?}", os);
}

License

The wmi crate is licensed under either of

Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)

at your option.