jna

How do I get a java JNA call to a DLL to get data returned in parameters?

那年仲夏 提交于 2019-12-01 01:42:34
I have this java test package ftct; import com.sun.jna.Library; import com.sun.jna.Native; import com.sun.jna.Platform; import com.sun.jna.win32.StdCallLibrary; import java.util.Date; public class LibFTCT { public LibFTCT() { } public interface LibFTCTLib extends StdCallLibrary { LibFTCTLib INSTANCE = (LibFTCTLib) Native.loadLibrary( "FTCTLib", LibFTCTLib.class); int a(int x); int DoCommand(int Command, int Param); int GetDataRecord(int RecordNum, int StreamNum, Date ReadingTime, double AIN1, double AIN2, double AIN3, double AIN4); } } It calls a Delphi DLL. If put the parameters as var in

Get running processes using JNA

倾然丶 夕夏残阳落幕 提交于 2019-12-01 01:21:29
I am trying to obtain a list of all currently running processes on a windows machine. I am trying it with winapi calls via JNA to EnumProcesses -> OpenProcess -> GetModuleBaseNameW -> CloseHandle It fails at the OpenProcess call. GetLastError returns 5 (ERROR_ACCESS_DENIED). This is my code: public static final int PROCESS_QUERY_INFORMATION = 0x0400; public static final int PROCESS_VM_READ = 0x0010; public static final int PROCESS_VM_WRITE = 0x0020; public static final int PROCESS_VM_OPERATION = 0x0008; public interface Psapi extends StdCallLibrary { Psapi INSTANCE = (Psapi) Native.loadLibrary

How to use C# function in Java using JNA lib

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 21:43:45
I've spent many hours trying to use a C# function inside my Java Application but had no success... I wrote the following lib in C#: public class Converter { public Converter() { } public bool ConvertHtmlToPdf(String directoryPath) { //DO SOMETHING } } This dll calls another dll to make some operations but when I compile it I can find Dlls in my Realse folder and everything seems to be ok, so I compiled it using 32bit option, 64bit, and Any CPU option just to make sure that it's not my issue. Analizing my dll files with Dependency Walker in 32 bit and Any CPU option it says that IESHIMS.DLL can

How do I make a target library available to my Java app?

妖精的绣舞 提交于 2019-11-30 21:31:15
Using JNA, the documentation says: Make your target library available to your Java program. There are two ways to do this: The preferred method is to set the jna.library.path system property to the path to your target library. This property is similar to java.library.path but only applies to libraries loaded by JNA. What does this actually mean? How do I set the jna.library.path system property? My app needs to reference Kernel32.dll Thanks You can set system properties by using the parameter "-D" when you invoke the Java Virtual Machine on the command line: java -Djna.library.path=<path to

Get running processes using JNA

孤者浪人 提交于 2019-11-30 20:33:31
问题 I am trying to obtain a list of all currently running processes on a windows machine. I am trying it with winapi calls via JNA to EnumProcesses -> OpenProcess -> GetModuleBaseNameW -> CloseHandle It fails at the OpenProcess call. GetLastError returns 5 (ERROR_ACCESS_DENIED). This is my code: public static final int PROCESS_QUERY_INFORMATION = 0x0400; public static final int PROCESS_VM_READ = 0x0010; public static final int PROCESS_VM_WRITE = 0x0020; public static final int PROCESS_VM

Cubieboard 3(cubietruck) 安装Jenkins

℡╲_俬逩灬. 提交于 2019-11-30 20:06:01
wget - q - O - http : / / pkg.jenkins - ci.org / debian / jenkins - ci.org.key | sudo apt - key add - sudo sh - c "echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list" sudo apt - get update sudo apt - get install jenkins jenkins 安装目录是 /var/lib/jenkins 启动/关闭 sudo /etc/init.d/jenkins start sudo /etc/init.d/jenkins stop log 路径 为 /var/log/jenkins/jenkins.log jenkins 修改 默认 访问端口 在cubietruck 报 异常 java.lang.UnsatisfiedLinkError 如: java.lang.UnsatisfiedLinkError:com.sun.jna.Native.open(Ljava/lang/String;)J atcom.sun.jna.Native.open(Native Method) atcom.sun.jna

JNA工作笔记二

我是研究僧i 提交于 2019-11-30 20:05:46
定义一个回调函数: //JNA CALLBACK方法定义,断线回调,如果你是标准的继承StdCallback,否则Callback public interface fDisConnect extends StdCallCallback { public int invoke(NativeLong lLoginID, String pchDVRIP, int nDVRPort, NativeLong dwUser); } JNA中的回调,采用的匿名内部类: /** * 断线回调 * * @return */ private static dhnetsdklibc.fDisConnect fDisConnect() { return new dhnetsdklibc.fDisConnect() { @Override public int invoke(NativeLong lLoginID, String pchDVRIP, int nDVRPort, NativeLong dwUser) { //注销订阅句柄 if (0 != m_lNativeRealPicHandle.longValue()) { DHUtil.clientStopLoadPic(m_lNativeRealPicHandle); logger.debug("取消订阅图片ok"); m

JNI --&-- JNA

别来无恙 提交于 2019-11-30 20:05:31
最近写SDK,解释下什么是SDK,SDK一般是一些被 软件工程师 用于为特定的 软件包 、软件框架、硬件平台、操作系统等建立 应用软件 的开发工具的集合。开发SDK时使用JNI去调用SO或DLL是一件多么痛苦的事情啊,痛苦的让我有点想去学C的冲动。首先来解释下SO和DLL吧,SO和DLL是使用C语言来写的一个共享库。下面说说使用JNI和JNA的具体步骤吧: 首先是让人灰常头痛的JNI: 一:生成NativeJNIHelloWord.java文件 public class NativeJNIHelloWord{ public native void displayHello(); static{ System.out.println("hello"); } static{ System.load("xx.so"); /* 加载so或dll,System.load2.System.load 参数为库文件的绝对路径,可以是任意路径。 例如你可以这样载入一个windows平台下JNI库文件: System.load("C:\\Documents and Settings\\TestJNI.dll");。 3. System.loadLibrary 参数为库文件名,不包含库文件的扩展名。 例如你可以这样载入一个windows平台下JNI库文件 System. loadLibrary (

how to get the process output when using jna and CreateProcessW

ぐ巨炮叔叔 提交于 2019-11-30 19:43:32
问题 I'm trying to figure out how to read the standard out/err from the process I've created with CreateProcessW. I looked at the docs, googled and searched this list but I didn't find good pointers/samples yet :) Here's what I came up with so far (it's working fine on windows, it's a relevant snippet from my java code): Kernel32 kernel32 = (Kernel32) Native.loadLibrary("kernel32", Kernel32.class); Kernel32.StartupInfo startupInfo = new Kernel32.StartupInfo(); Kernel32.ProcessInfo

JNA library slower screenshot than robot class?

大兔子大兔子 提交于 2019-11-30 18:33:00
Since Robot.createScreenCaputure() method is slow, I decided to use native library. I searched and found this forum and find a specific code snipplet which uses JNA Library . It's an old version so that I rewrote the code: import java.awt.Rectangle; import java.awt.image.BufferedImage; import java.awt.image.ColorModel; import java.awt.image.DataBuffer; import java.awt.image.DataBufferInt; import java.awt.image.DataBufferUShort; import java.awt.image.DirectColorModel; import java.awt.image.Raster; import java.awt.image.WritableRaster; import com.sun.jna.Native; import com.sun.jna.win32