use std::{thread};
use wmi::{COMLibrary, WMIConnection};

use crate::dtos::bios::{BiosInfo, Win32_BIOS};

pub fn get_bios_info() -> BiosInfo {
    thread::spawn(|| {
        let com_con = COMLibrary::new().unwrap();
        let wmi_con = WMIConnection::new(com_con.into()).unwrap();

        let results: Vec<Win32_BIOS> = wmi_con.query().unwrap();
        let win32_bios = results.first().unwrap();

        BiosInfo {
            uuid: win32_bios.SerialNumber.clone(),
            manufacturer: win32_bios.Manufacturer.clone(),
            name: format!("{} {}", win32_bios.Version, win32_bios.ReleaseDate),
        }
    }).join().unwrap()
}
