wincom 0.3.0

A lightweight Rust wrapper for Windows COM IDispatch automation, providing RAII VARIANT management and simplified property/method invocation.
Documentation
mod common;
use common::ComGuard;

use windows::core::{GUID, HSTRING};
use windows::Win32::System::Com;

const PPT_CLSID: GUID = GUID::from_u128(0x91493441_5A91_11CF_8700_00AA0060263B);
const PPT_CLSID_STR: &str = "{91493441-5A91-11CF-8700-00AA0060263B}";
const PPT_PROGID: &str = "PowerPoint.Application";

#[test]
fn test_clsid_from_prog_id() {
    let _com = ComGuard::init().expect("CoInitialize failed");
    match unsafe { Com::CLSIDFromProgID(&HSTRING::from(PPT_PROGID)) } {
        Ok(clsid) => println!("ProgID -> CLSID = {clsid:?}"),
        Err(e) => eprintln!("skip: ProgID not registered ({e})"),
    }
}

#[test]
fn test_clsid_from_string() {
    let _com = ComGuard::init().expect("CoInitialize failed");
    match unsafe { Com::CLSIDFromString(&HSTRING::from(PPT_CLSID_STR)) } {
        Ok(clsid) => println!("String -> CLSID = {clsid:?}"),
        Err(e) => eprintln!("CLSIDFromString failed: {e}"),
    }
}

#[test]
fn test_clsid_from_prog_id_matches_string() {
    let _com = ComGuard::init().expect("CoInitialize failed");

    let from_prog = match unsafe { Com::CLSIDFromProgID(&HSTRING::from(PPT_PROGID)) } {
        Ok(c) => c,
        Err(e) => {
            eprintln!("skip: {PPT_PROGID} not registered ({e})");
            return;
        }
    };
    let from_str = unsafe { Com::CLSIDFromString(&HSTRING::from(PPT_CLSID_STR)) }
        .expect("valid GUID string");

    assert_eq!(from_prog, PPT_CLSID);
    assert_eq!(from_str, PPT_CLSID);
    assert_eq!(from_prog, from_str);
}