contextfree / winrt-rust

Use and (eventually) make Windows Runtime APIs with Rust
Apache License 2.0
142 stars 10 forks source link

Using COM components? #81

Closed paddyhoran closed 5 years ago

paddyhoran commented 5 years ago

Is it possible to control applications that expose a COM API with this library? I'm sorry if this is an obvious question.

An example is probably best. In Python I can do the following via pywin32:

    win32.pythoncom.CoInitialize()
    outlook = win32.Dispatch('outlook.application')
    mail = outlook.CreateItem(0)
    mail.To = 'some address'
    mail.Subject = 'Subject'
    mail.body = 'Body'
    mail.send

I know that WinRT is a different technology to COM but I'm wondering if there is interoperability to the point that this crate could be used for a use case like the above?

Thanks

Boddlnagg commented 5 years ago

Although one could reuse some internal components of winrt-rust to do such a thing (e.g. BSTR, which doesn't actually belong in this crate, and ComPtr), those are implementation details and not meant to be used by consumers directly (and eventually even completely hidden from the public API).

The point of winrt-rust is the automatic wrapper code generation for WinRT based on WinRT metadata, and that is not available for plain COM.

You might have more luck with something like com_rs or wio-rs, which also provides a ComPtr.

paddyhoran commented 5 years ago

Ok, I thought so, thanks for the confirmation.