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;
use windows::Win32::System::Com;
use wincom::ComObject;

const CDR_CLSID: GUID = GUID::from_u128(0xED740002_0830_48CB_98A7_AA817C56004F);
const CDR_PROGID: &str = "CorelDRAW.Application";

#[test]
#[ignore = "starts a new CorelDRAW process; run manually"]
fn test_new_from_name() {
    let _com = ComGuard::init().expect("CoInitialize failed");
    match ComObject::new_from_name(CDR_PROGID, CDR_CLSID) {
        Ok(app) => println!("created instance: clsid = {:?}", app.iid()),
        Err(e) => eprintln!("skip: {CDR_PROGID} not installed ({e})"),
    }
}

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

    let clsid = match unsafe {
        Com::CLSIDFromProgID(&windows::core::HSTRING::from(CDR_PROGID))
    } {
        Ok(c) => c,
        Err(e) => {
            eprintln!("skip: {CDR_PROGID} not registered ({e})");
            return;
        }
    };

    assert_eq!(clsid, CDR_CLSID, "ProgID does not resolve to expected CLSID");
    println!("{CDR_PROGID} -> {clsid:?}");
}