10 unstable releases (3 breaking)

✓ Uses Rust 2018 edition

0.4.6 Oct 17, 2019
0.4.5 Sep 24, 2019
0.4.4 Jun 11, 2019
0.3.0 May 28, 2019
0.1.1 Apr 14, 2019

#16 in Windows APIs

Download history 57/week @ 2019-06-30 59/week @ 2019-07-07 6/week @ 2019-07-14 11/week @ 2019-07-21 10/week @ 2019-07-28 43/week @ 2019-08-04 31/week @ 2019-08-11 18/week @ 2019-08-18 57/week @ 2019-08-25 40/week @ 2019-09-01 34/week @ 2019-09-08 81/week @ 2019-09-15 113/week @ 2019-09-22 25/week @ 2019-09-29 10/week @ 2019-10-06

158 downloads per month

MIT/Apache

90KB
2K SLoC

wmi

Build Status crates.io

Documentation

WMI crate for rust. Currently in beta.

# Cargo.toml
[dependencies]
wmi = "0.4"

Examples

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

use serde::Deserialize;
use wmi::{COMLibrary, Variant, WMIConnection, WMIDateTime};
use std::collections::HashMap;

fn main() -> Result<(), Box<dyn std::error::Error>>  {
    let com_con = COMLibrary::new()?;
    let wmi_con = WMIConnection::new(com_con.into())?;
    
    let results: Vec<HashMap<String, Variant>> = wmi_con.raw_query("SELECT * FROM Win32_OperatingSystem")?;
    
    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()?;
    
    for os in results {
        println!("{:#?}", os);
    }
    
    Ok(())
}

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.

Dependencies

~0.8–1.8MB
~38K SLoC