Windows-rs: Requesting an example of how to implement a COM interface

Created on 22 Jan 2021  路  7Comments  路  Source: microsoft/windows-rs

I have a fairly simple C++ program that turns on a blink(1) based on a capture device's mute state.

I'd love to port that code to Rust, if possible, but I don't know how to implement the IMMNotificationClient or IAudioEndpointVolumeCallback interfaces.

I noticed that there is the implement macro, but the documentation seems a bit sparse. If there is an example of how to do this, could you point me toward it, and if not, I humbly request one!

documentation enhancement

Most helpful comment

The implement macro currently only supports WinRT interfaces, but I am working on adding support for COM interfaces like IAudioEndpointVolumeCallback and should be coming soon.

All 7 comments

The implement macro currently only supports WinRT interfaces, but I am working on adding support for COM interfaces like IAudioEndpointVolumeCallback and should be coming soon.

Thanks for working on this, I need to be able to implement DirectShow filters 馃槄

I'm also affected by this, in the meantime, is there some way to implement interfaces by hand?

Implementing COM interfaces from scratch is non-trivial but very much possible. It does take quite a bit of knowledge of how COM works under the hood though. You can have a look at https://github.com/microsoft/com-rs (specifically the code gen aspects of that crate) for some clues.

Duplicate of #81 - working on it.

I'm also affected by this, in the meantime, is there some way to implement interfaces by hand?

Here's an example of implementing drag&drop com interfaces by hand. It is doable but less than ideal. A macro would be very welcome indeed :)

That's all I am working on at the moment. 馃槈

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rylev picture rylev  路  4Comments

joverwey picture joverwey  路  3Comments

tim-weis picture tim-weis  路  3Comments

DJankauskas picture DJankauskas  路  3Comments

13r0ck picture 13r0ck  路  4Comments