简体   繁体   English

JNA 中的 Oleacc dll 支持

[英]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.我正在尝试使用 JNA 库为我正在处理的 Java 项目调用 Oleacc dll 的AccessibleObjectFromWindow方法。

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.我浏览了 JNA 文档并在线搜索了一个示例,但找不到在 Oleacc dll 和 JNA 中使用AccessibleObjectFromWindow的良好参考。

Can someone having a good background on JNA library please confirm whether JNA includes Oleacc dll's functionality?有人可以在 JNA 库方面有良好的背景,请确认 JNA 是否包含 Oleacc dll 的功能?

If not any alternatives to using Oleacc dll from a Java program is also much appreciated.如果没有从 Java 程序中使用 Oleacc dll 的任何替代方法,也非常感谢。

Thanks..!谢谢..!

When you ask the question "JNA includes" it's helpful to point out there are two portions of the JNA project.当您问“JNA 包括”这个问题时,指出 JNA 项目有两个部分会很有帮助。 There's the jna artifact, which includes core functionality, and the jna-platform artifact which contains user-submitted mappings of JNA for various platforms.有包含核心功能的jna工件,以及包含用户提交的用于各种平台的 JNA 映射的jna-platform工件。 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:)" .我强调“用户提交”,因为 JNA 是一个社区维护的项目,并且“JNA 在其平台库映射中缺少 function XXX”的常见问题解答是“不,不是,它只是在等你添加它:)” .

The Oleacc dll is one of those instances. Oleacc dll 就是其中之一。 It's not yet in the jna-platform artifact, but it could be if a user submitted it.它还没有出现在jna-platform工件中,但如果用户提交了它,它可能会出现。 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!例如,请参阅2015 年的一个用户自己映射了这个库,但没有将它贡献给社区,所以在 5 年后,您将重现该努力,如果您在该 JNA 问题中向下滚动,您将看到一些示例代码实现您的方法和其他一些方法,如果您能为 JNA 做出贡献,那就太棒了!

Meanwhile, when a mapping isn't in JNA, the above FAQ link gives a template for how to implement it.同时,当映射不在 JNA 中时,上面的 FAQ 链接提供了如何实现它的模板。 In your specific case, the code to implement AccessibleObjectFromWindow would be simple for you to do in your own project.在您的具体情况下,实现AccessibleObjectFromWindow的代码对您来说很简单,您可以在自己的项目中执行此操作。 Create an Oleacc class with these contents:使用以下内容创建 Oleacc class:

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! JNA 中的映射也是如此,不,但希望在您实现它并测试您的代码之后,您可以将您的映射贡献给项目,以便下一个需要这样做的人可以在 JNA 中找到它!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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