简体   繁体   中英

Oleacc dll support in JNA

I am trying to use the JNA library for calling the Oleacc dll's AccessibleObjectFromWindow method for a Java project that I am working on.

I went through the JNA documentation as well as searched for an example online but could not find a good reference for using AccessibleObjectFromWindow in Oleacc dll with JNA.

Can someone having a good background on JNA library please confirm whether JNA includes Oleacc dll's functionality?

If not any alternatives to using Oleacc dll from a Java program is also much appreciated.

Thanks..!

When you ask the question "JNA includes" it's helpful to point out there are two portions of the JNA project. There's the jna artifact, which includes core functionality, and the jna-platform artifact which contains user-submitted mappings of JNA for various platforms. I highlight "user-submitted" as JNA is a community maintained project, and the FAQ answer to "JNA is missing function XXX in its platform library mappings" is "No, it's not, it's just waiting for you to add it:)" .

The Oleacc dll is one of those instances. It's not yet in the jna-platform artifact, but it could be if a user submitted it. See, for example, a user in 2015 mapped this library themselves, but did not contribute it to the community, so here you are 5 years later reproducing that effort, If you scroll down in that JNA issue you'll see some sample code implementing your method and a few others, that it would be fantastic if you could contribute to JNA!

Meanwhile, when a mapping isn't in JNA, the above FAQ link gives a template for how to implement it. In your specific case, the code to implement AccessibleObjectFromWindow would be simple for you to do in your own project. Create an Oleacc class with these contents:

public interface Oleacc extends StdCallLibrary, WinUser, WinNT {

    Oleacc INSTANCE = (Oleacc) Native.loadLibrary("oleacc", Oleacc.class, W32APIOptions.DEFAULT_OPTIONS);

    HRESULT AccessibleObjectFromWindow(HWND win, int objID, Guid.REFIID iid, PointerByReference ptr);
}

And you're done? So is that mapping in JNA yet, No, but hopefully after you've implemented it and tested your code, you can contribute your mapping to the project so that the next person who needs to do so can find it in JNA!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM