从 Java 调用 Win32 API 方法 [英] Calling Win32 API method from Java
问题描述
我需要调用 Wininet.dll 中的一些方法 来自 Java 程序.
I need to call some methods in Wininet.dll from a Java program.
我可以找到很多关于如何调用我从 Java 创建的新 DLL 的教程,但我似乎找不到任何关于如何从 Java 调用现有 DLL 的教程.
I can find plenty of tutorials on how to call a new DLL that I create from Java, but I can't seem to find any tutorials on how to call an already existing DLL from Java.
我知道这涉及到 JNI,但是我到底该怎么做呢?我需要在 Wininet.h 上调用 javah
吗?在哪里可以获得 Wininet.h 的副本?指向现有的详细教程就足够了.
I know this involves JNI, but how, exactly, do I do this? Do I need to call javah
on Wininet.h? Where do I get a copy of Wininet.h? A pointer to an existing, detailed tutorial would be sufficient.
推荐答案
JNA seems the industry standard of what you want, "provides Java programs easy access to native shared libraries (DLLs on Windows) without writing anything but Java code—no JNI or native code is required"
还有 Java 外部函数接口 -示例用法
如果您觉得合适,您可以嵌入 JRuby 解释器并通过 jruby-ffi<调用 winapi/a> 这要容易得多,请参阅此处,这里,和这里
There is also Java Foreign Function Interface -
example usage
If is ok for you, you could embed the JRuby interpreter and call winapi via jruby-ffi wich is a lot easier, see here, here, and here
这篇关于从 Java 调用 Win32 API 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!