com4j | Type-safe Java/COM binding
kandi X-RAY | com4j Summary
kandi X-RAY | com4j Summary
Type-safe Java/COM binding
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of com4j
com4j Key Features
com4j Examples and Code Snippets
Community Discussions
Trending Discussions on com4j
QUESTION
I've managed to get COM4J to use some functionality in the windows IMAPI (CD writing).
However I've failed to get any of the calls that return SAFEARRAYs working, but this project doesn't appear to be currently active ...
The DLL is usually in C:\Windows\System32\imapi2.dll, and using it also requires using C:\Windows\System32\imapi2fs.dll
Looking around for a JAVA-COM bridge project that is active led me to JNA.
The remit of the project to simplify JAVA-COM bridging intrigued me .... however I fell at the first hurdle, and am hoping someone can help.
So far I've taken the Microsoft IMAPI examples and written a Powershell application, from which I have the series of calls I need to make to the API.[CDInterface][1]
The first thing you need to do with IMAPI is create an Instance of IDiskMaster2, so I've declared that via an Imapi2 interface, like so
...ANSWER
Answered 2021-Nov-26 at 19:15I've answered this in a similar question which I originally marked this as a duplicate of. However, given the difficulty loading this, your case is unique enough that I'll attempt to give a separate answer.
The general case for COM is that there is an API function that creates the object. You have mapped this as createMsftDiscMaster2()
. Note that you have allocated a resource here and it needs to be disposed of when you are done with it; the API documentation should tell you how to do that (possibly by calling Release()
from IUnknown
.)
Your next step is to map the IDiscMaster2
COM class. I see two mappings here, so I'm confused as to which one you want. The one at the top of your question is incorrect, but the one extending Dispatch later is the correct way to start, but I'm not clear where you've gone after that. The rest of the class should look similar to the internals of the Dispatch
class in JNA.
In that class you can see the boilerplate that you will follow. Note that it extends Unknown
which follows the same boilerplate for offsets 0, 1, and 2 for the first 3 COM functions QueryInterface
, AddRef
, and Release
. Dispatch picks up with offsets 3, 4, 5, and 6 for COM functions GetTypeInfoCount
, GetTypeInfo
, GetIDsOfNames
, and Invoke
.
So in your mapping for DiskMaster2
you will pick up with offset 7, and your mapping will look like:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install com4j
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page