A command-line tool that extracts COM object type information and generates Rust code in windows-rs interface macro format.
- Extract COM interface information using
IProvideClassInfo - Multiple output formats:
- Rust: Generate code in windows-rs
interfacemacro format - JSON: Structured JSON output
- Rust: Generate code in windows-rs
- Search by GUID or ProgID
- Output to stdout or file
# Generate Rust code from GUID (stdout)
com-interface-gen --guid "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
# Generate from ProgID
com-interface-gen --progid "Shell.Application"
# Output as JSON
com-interface-gen --guid "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" --format json
# Output to file
com-interface-gen --guid "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" --output output.rsOptions:
-g, --guid <GUID> GUID of the COM class (format: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX)
-p, --progid <PROGID> ProgID of the COM class (alternative to GUID)
-f, --format <FORMAT> Output format [default: rust] [possible values: json, rust]
-o, --output <FILE> Output file path (stdout if not specified)
-h, --help Print help
use windows::{
Win32::System::{Com::{IDispatch, IDispatch_Impl, IDispatch_Vtbl}, Variant::VARIANT},
core::{BSTR, HRESULT, OutRef, interface},
};
/// version: 1.0
/// IShellDispatch Interface
// DUAL|DISPATCHABLE
// DISPATCH
#[interface("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")]
pub unsafe trait IShellDispatch: IDispatch {
// ...
}{
"guid": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"name": "IShellDispatch",
"doc": "IShellDispatch Interface",
"kind": "DISPATCH",
"flags": "DUAL|DISPATCHABLE",
"functions": [...]
}This tool uses the following Windows COM APIs:
IProvideClassInfo::GetClassInfo()- Retrieve COM class type informationITypeInfo- Read interface metadataCLSIDFromProgID()- Convert ProgID to CLSID
This is an experimental prototype with the following limitations:
- Pointer and array return types are not supported (causes
todo!()panic) - Limited VARIANT type support (
VT_BSTR,VT_I4,VT_VARIANT,VT_INT,VT_UI4,VT_UI2,VT_UINT,VT_BOOL,VT_I1) - Unsupported types will cause
todo!()panic - Tested only with specific COM components
Intended use: Prototyping, investigation, and learning purposes only. Not recommended for production use.
- Windows OS
- Target COM object must be registered on the system