mod common;
use common::ComGuard;
use windows::core::HSTRING;
use wincom::ComObject;
#[test]
fn test_app_from_path() {
let _com = ComGuard::init().expect("CoInitialize failed");
let progid = "CorelDRAW.Application";
let clsid = match unsafe {
windows::Win32::System::Com::CLSIDFromProgID(&HSTRING::from(progid))
} {
Ok(id) => id,
Err(e) => {
eprintln!("skip: cannot resolve ProgID {progid}: {e}");
return;
}
};
println!("[{progid}] CLSID = {clsid:?}");
match ComObject::new_from_active(progid) {
Ok(app) => {
println!("bound to running instance of {progid}");
if let Ok(v) = app.get_property("Version") {
match v.to_string() {
Ok(s) => println!("Version = {s}"),
Err(e) => println!("Version read but cast failed: {e}"),
}
}
}
Err(e) => {
println!("no running instance of {progid}: {e}");
}
}
}