Project

General

Profile

Actions

Feature #14348

open

win32ole: enable using coclass-es with multiple IDispatch implementations

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

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:84809]

Description

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'
TYPELIB = WIN32OLE_TYPELIB.new(LIBNAME)

lic = 'xxxx'

foo = WIN32OLE.new(
  TYPELIB.ole_type.find { |t| t.name == 'Foo' },
  nil,
  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 ^_^


Files

Actions #1

Updated by graywolf (Gray Wolf) about 6 years ago

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

Also available in: Atom PDF

Like0
Like0