Feature #14348

win32ole: enable using coclass-es with multiple IDispatch implementations

Added by graywolf (Gray Wolf) about 3 years ago. Updated about 3 years ago.

Target version:


Currently win32ole requires coclass to directly implement (one) IDispatch. That
works fine for

coclass Good {
    [default] interface GoodIface2;
    interface GoodIface1;

interface GoodIface1 : IDispatch {
    // snip

interface GoodIface2 : GoodIface1 {
    // snip

however, it fails to work for the following

coclass Bad {
    [default] interface BadIface1;
    interface BadIface2;

interface BadIface1 : IDispatch {
    // snip

interface BadIface2 : IDispatch {
    // snip

I suspect it's because when you ask for IDispatch of Bad, it doesn't know
which one to give you (but I'm no COM expert so correct me if I'm wrong).

Now, please let's not discuss if classes like that are good idea or not (I
think they are not), fact is they do exists and simple patch allows using them
with ruby's win32ole.

Attached patch adds new iface keyword argument which let's you pick interface
to acquire (it must still implement IDispatch). Documentation also says that
you very likely do NOT need to use this argument.

Usage in my particular case would look like this:

LIBNAME = 'xxx'

lic = 'xxxx'

foo =
  TYPELIB.ole_type.find { |t| == 'Foo' },
  license: lic,
  iface: '{00000000-0000-0000-0000-000000000000}'

foo.Bar(1, 2, 'foobar')

as you can see, except for the need to specify the interface, it works exactly
same as normal classes.

Please consider for merge ^_^



Updated by graywolf (Gray Wolf) about 3 years ago

  • Subject changed from win32ole: enable using a bit weirder classes than usual to win32ole: enable using coclass-es with multiple IDispatch implementations

Also available in: Atom PDF