1

I'm trying to use com4j to set up a simple Java app which can interact with the IDispatch COM interface. Normally with com4j you would use the tlbimp.jar tool to generate a com4j Java interface whose instances will proxy IDispatch. The com4j docs say:

Usually, the first step of using com4j is to generate Java type definitions from a COM type library. COM type libraries are often found in .ocx, .dll, .exe, and/or .tlb files. I still don't know how to locate type libraries for a given COM library other than guessing the file by using OleView.

Does anyone know where to look for a type library which defines IDispatch?

0xbe5077ed
  • 4,565
  • 6
  • 35
  • 77
  • I'm pretty sure there is no type library describing `IDispatch`. The TLB format is simply not rich enough to represent its intricacies. However, you likely don't need to interact with `IDispatch` in general, but with a particular implementation of it, also known as a dispinterface. That dispinterface may very well be described in a type library, which is usually shipped together with the component (either as a separate file, or bound to the binary as a resource). Which component do you want to work with, if you don't mind me asking? – Igor Tandetnik Oct 02 '13 at 03:39
  • Thanks for the reply, Igor. I'm indeed looking for the actual `IDispatch` interface. Here's the use case: I want to be able to expose `IDispatch` pointers to a dynamic language, called [Suneido](http://sourceforge.net/projects/suneido/), which is implemented in Java. Say the Suneido programmer has a reference to an `IDispatch `, x. Suneido lets him dynamically change properties and call methods on the `IDispatch` with syntax like `x.Property = 5` or `val = x.Method()` where the properties and methods are looked up dynamically at runtime. So I actually only want to interact with `IDispatch`... – 0xbe5077ed Oct 03 '13 at 00:55
  • Ah. Turns out, there **is** a TLB file containing `IDispatch`. Name's `stdole2.tlb`, on my machine it's under `C:\Windows\winsxs\x86_microsoft-windows-ole-automation-stdole2_31bf3856ad364e35_6.1.7600.16385_none_e8ad19677a48df45` (gotta love side-by-side). See if this helps. – Igor Tandetnik Oct 03 '13 at 01:59
  • I had a hunch about this yesterday and tried to run `tlbimp.jar` on it (actually I tried the one in `C:\Windows\System32\stdole2.tlb` and `stdole32.tlb`). Today I tried the one you suggested. The problem is `tlbimp.jar` generates no output at all for this TLB! It also generates no error message so I can't tell why it is failing, or at what point. **Are you able to generate any output from this TLB?** – 0xbe5077ed Oct 03 '13 at 03:07
  • I'm not familiar with `tlbimp.jar` or `com4j` or, really, anything Java, I'm sorry to say. I can't help you on that side. Having said that, I kind of expected something like this to happen. It is a good bet this `com4j` thing knows how to deal with run of the mill automation interfaces. But `IDispatch` is not one of those. See if [something like this](https://code.google.com/p/nativelibs4java/source/browse/trunk/libraries/Runtime/BridJ/src/main/java/org/bridj/cpp/com/IDispatch.java?r=2035) helps (found by a quick Google search for "Java IDispatch") – Igor Tandetnik Oct 03 '13 at 04:40

0 Answers0