jna

JNA Event Log Reader

两盒软妹~` 提交于 2019-12-28 16:16:12
问题 I am using the below code to read through the Windows Application Event Log using JNA. I want to be able to specify which event to start at instead of always starting with the first event. Does anyone have any suggestions? import java.io.IOException; import com.sun.jna.*; import com.sun.jna.platform.win32.*; import com.sun.jna.platform.win32.WinNT.*; import com.sun.jna.ptr.IntByReference; public class test { public static void main(String[] args) throws NumberFormatException, IOException {

Using JNA to link to custom dll

 ̄綄美尐妖づ 提交于 2019-12-28 12:31:09
问题 how do I access custom .lib / .dll functions using JNA? Can someone provide an example? Thank you. 回答1: Example (from Wikipedia): import com.sun.jna.win32.StdCallLibrary; import com.sun.jna.Native; /** Simple example of Windows native library declaration and usage. */ public class BeepExample { public interface Kernel32 extends StdCallLibrary { // FREQUENCY is expressed in hertz and ranges from 37 to 32767 // DURATION is expressed in milliseconds public boolean Beep(int FREQUENCY, int

How to call a method in DLL in a Java program

随声附和 提交于 2019-12-28 08:11:25
问题 I am trying to call a method in a DLL using JNA. So far have loaded the DLL using Runtime.getRuntime().load("myworkspace/test.dll"); This dll contaings a method that I need to access. How can I execute the method present in DLL in my Java file. Do I create an object or something of the DLL and then get the method name after the dot operator. 回答1: From the source: package jnahelloworldtest; import com.sun.jna.Library; import com.sun.jna.Native; import com.sun.jna.NativeLong; import com.sun.jna

JNA粗浅的一些讲解

对着背影说爱祢 提交于 2019-12-28 03:10:23
1.JNA是什么 JNA(Java Native Access )提供一组Java工具类用于在运行期动态访问系统本地库(native library:如Window的dll)而不需要编写任何Native/JNI代码。开发人员只要在一个java接口中描述目标native library的函数与结构,JNA将自动实现Java接口到native function的映射。 2.通过JNA调用DLL 首先我们导入JNA支持的jar包:jna-5.4.0.jar,jna-platform-5.4.0.jar 使用代码调用DLL动态库,举例说明: // Alternative 1: interface-mapped class, dynamically load the C library public interface CLibrary extends Library { CLibrary INSTANCE = ( CLibrary ) Native . loadLibrary ( "c" , CLibrary . class ) ; } // Alternative 2: direct-mapped class (uses a concrete class rather than an // interface, with a slight variation in method //

java使用jna调用dll

安稳与你 提交于 2019-12-26 21:23:23
java中使用jna方式调用dll http://blog.csdn.net/a491857321/article/details/51504094 http://blog.csdn.net/a936676463/article/details/50082277 java中jna参数对照表 https://github.com/java-native-access/jna/blob/master/www/Mappings.md jna指针 http://www.cnblogs.com/armlinux/archive/2009/07/20/2390971.html 64位winIo http://www.cnblogs.com/lilixiang-go/p/4710643.html winIo资料 http://download.csdn.net/detail/u012968101/9107473 http://wenku.baidu.com/link?url=8WgfoJEusRGmUMJXISRqUB7UdP5FNUbqu05F7dSMx9rDEH5jBpBDHyAVIU1_p4JiCItI9vLJqgeYh94niQl8sJCqo1trPhYbKhnixetFcyW http://yuebo85.iteye.com/blog/1392530 找不到dll http:/

Java use JNA call dll error:Invalid memory access

落花浮王杯 提交于 2019-12-25 12:22:25
问题 I want to call dll to write/read from hardware.However, I get the error below: dll method: int NewKey(char *room,char *gate,char *stime,char *guestname,char *guestid, int overflag, int Breakfast, long *cardno,char * track1,char * track2); java method: int NewKey(String room, String gate,String time,String guestname,String guestid, int overflag, int Breakfast, NativeLongByReference cardno, String track1, String track2); The api document shows cardno as a out parameter and track1,track2 could

Java use JNA call dll error:Invalid memory access

时光总嘲笑我的痴心妄想 提交于 2019-12-25 12:22:12
问题 I want to call dll to write/read from hardware.However, I get the error below: dll method: int NewKey(char *room,char *gate,char *stime,char *guestname,char *guestid, int overflag, int Breakfast, long *cardno,char * track1,char * track2); java method: int NewKey(String room, String gate,String time,String guestname,String guestid, int overflag, int Breakfast, NativeLongByReference cardno, String track1, String track2); The api document shows cardno as a out parameter and track1,track2 could

Decrypt Data which was encrypted with MS DPAPI with JNA

ⅰ亾dé卋堺 提交于 2019-12-25 07:07:12
问题 is it possible to decrypt data which was encrypted with MS DPAPI? For example i want to decrypt a digital certificate from the windows registry. byte[] byteArray = (byte[]) Advapi32Util.registryGetValue(WinReg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\SystemCertificates\\AuthRoot\\Certificates\\02FAF3E291435468607857694DF5E45B68851868", "Blob"); byte[] decrypted = Crypt32Util.cryptUnprotectData(byteArray); String stringDecrypted = new String(decrypted); System.out.println(stringDecrypted);

Wrap a DLL into Java

陌路散爱 提交于 2019-12-25 05:09:15
问题 I've got some code to talk to a hardware device on windows which is working in C++. The code does something pretty simple to react to a button push on the device and I have this compiled into a dll with an observer that is called when the button is pushed. I now need to interface this with a big Java program. I was intending to use JNA but it only works with C and I cannot see how to do this with an Observer pattern in C. I've looked into using BridJ and SWIG (both of which cliam to work on C

Jna, Unload Dll from java class dynamically

左心房为你撑大大i 提交于 2019-12-25 04:33:11
问题 I have googled bit , but dint find way to unload dll using JNA ,from java Class. And as i am using dll to transfer data from usb device using this dll, i have to unload my dll from java class in order to re-use my usb device with same class without closing my whole program. here is how i load my dll using JNA public interface UsbSensor extends Library { UsbSensor INSTANCE = (UsbSensor) Native.loadLibrary( (Platform.isWindows() ? "D:\\UsbDevice.dll" : "D:\\UsbDevice.dll"), UsbSensor.class);