从 Java 调用 Win32 API 方法 [英] Calling Win32 API method from Java

查看:72
本文介绍了从 Java 调用 Win32 API 方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要调用 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.

推荐答案

  1. JNA 似乎是 您想要的行业标准,为 Java 程序提供对本地共享库(Windows 上的 DLL)的轻松访问,而无需编写除 Java 代码之外的任何内容—没有 JNI 或本机代码是必需的"

  1. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆