java 如何在java中使用winapi函数?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2172520/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to use winapi functions in java?
提问by arindam
I am doing a project in java which has the function to add files in database, and i want to use winapi functions to select files. How would i do that?
我正在用java做一个项目,它具有在数据库中添加文件的功能,我想使用winapi函数来选择文件。我该怎么做?
回答by Mavrik
By far the easiest way is by using Java JNA, it already has translation from stcalls in.
到目前为止,最简单的方法是使用Java JNA,它已经有来自 stcalls 的翻译。
You can find a basic tutorial for it (with Winapi example no less) on JavaWorld.
您可以在JavaWorld上找到它的基本教程(使用 Winapi 示例)。
You could also use JNI, but JNI requires you to use specially built header files for interfacing and it's all in all harder to maintain and use. It's slightly faster in some cases though.
您也可以使用 JNI,但 JNI 要求您使用专门构建的头文件进行接口,而且总体上更难维护和使用。不过在某些情况下它会稍微快一点。
回答by arindam
You want Java Native Interface - this tutorial shows you how to implement your own but you could easily just point to WinAPI functions - http://java.sun.com/docs/books/jni/download/jni.pdf
您需要 Java Native Interface - 本教程向您展示了如何实现自己的接口,但您可以轻松地指向 WinAPI 函数 - http://java.sun.com/docs/books/jni/download/jni.pdf
Here's an example I found with a quick Google - not the neatest webpage but still demonstrates the concept well http://edn.embarcadero.com/article/20679
这是我用快速谷歌找到的一个例子 - 不是最简洁的网页,但仍然很好地展示了这个概念http://edn.embarcadero.com/article/20679
回答by Deniz Acay
I strongly advise JACOB (Java COM Bridge) for using COM interfaces. http://sourceforge.net/projects/jacob-project/
我强烈建议 JACOB (Java COM Bridge) 使用 COM 接口。 http://sourceforge.net/projects/jacob-project/
I wrote an app for getting song infos from Amazon Web Services. Its a nice library to have.
我编写了一个应用程序,用于从 Amazon Web Services 获取歌曲信息。它是一个不错的图书馆。

