Comments (5)
I think this should be as simple as creating an IDispatch annotated interface (see http://com4j.java.net/annotations.html), and invoking the method on it. Since IDispatch is just a COM interface like any other I don't think COM4J itself needs to have any special support for this.
from com4j.
I started down that path:
@IID(IID.IDispatch)
public interface IDispatch extends Com4jObject
{
@VTID(3)
int getTypeInfoCount();
@VTID(5)
int getIDsOfName(Object riid, String[] names, int count, @LCID int lcid);
}
The getTypeInfoCount method works, but the getIDsOfName method does not. Is there a tlb, ocx or dll that I can generate this from? I searched google and my Windows system32 directory, but couldn't find anything. Otherwise some hints on what these methods need to look like would be appreciated.
from com4j.
I think you are on the right track, but your signature for getIDsOfName is wrong. If you read MSDN for that method, it expects a pointer to a caller allocated buffer that it will fill...so you need something like:
@VTID(5)
@returnvalue(type=NativeType.HRESULT)
int getIDsOfNames(Object riid, String[] names, int count, @LCid int lcid, ByteBuffer buffer);
Then when you call it you would pass a byte buffer of the correct size (names.length * 4) allocated with ByteBuffer.allocateDirect.
I think IDispatch may be defined in the stdole32.tlb, but I'm not sure.
While I was looking at the MSDN I also saw this note which seems like it applies to what you are trying to do:
Caution You cannot use this method to access values that have been added dynamically, such as values added through JavaScript. Instead, use the GetDispID of the IDispatchEx interface. For more information, see the IDispatchEx interface.
from com4j.
Ah, you are correct, IDispatchEx is a better choice. I am able to create a working com4j interface for IDispatchEx. Thanks for the help!
from com4j.
Hi @scheidh -- Would you mind sharing your annotated code for IDispatchEx? I'm trying to get make an annotated interface for vanilla IDispatch but I don't know what to do for the Invoke() method.
from com4j.
Related Issues (20)
- Some methods subscribers are not invoked
- error in namespace generation with maven plugin
- java.lang.IllegalArgumentException HOT 1
- Does it support, work with java9?
- Java definitions from a dll-library
- 3rd party libraries
- Unmarshal proper types for the elements of Collections ? HOT 1
- Marshalling between threads when using COM4J.wrap
- Methods with return type void fail when using default values
- When converting from VARIANT to Java type the target type should be boxed
- Memory corruption on IBM Websphere 9
- can you give me a demo for callback?
- UDP ports not being closed HOT 1
- Crash with openj9
- An unrecoverable stack overflow has occurred
- PortableDeviceAPI : "[ERROR] Unable to handle the type"
- Cannot convert Variant to double[]
- IADsUser.accountExpirationDate() uses wrong epoch time for date calculations HOT 1
- Download Distribution link doesnt work HOT 1
- ISearchQueryHelper::get_ConnectionString unexpected conversion type: 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from com4j.