jna

How can I call a Delphi function that returns a string using JNA?

混江龙づ霸主 提交于 2019-11-28 07:44:29
问题 I'm working on calling functions from a Delphi compiled *.so file from a Java program. After some research it seems like JNA is he way to go. Before diving into some complex Delphi code, I'm trying to play with some "Hello World" code but am having trouble getting a string returned by a Delphi function. The Delphi code (helloworld.pp): library HelloWorldLib; function HelloWorld(const myString: string): string; stdcall; begin WriteLn(myString); Result := myString; end; exports HelloWorld;

Using JNA to link to custom dll

∥☆過路亽.° 提交于 2019-11-28 07:42:05
how do I access custom .lib / .dll functions using JNA? Can someone provide an example? Thank you. luiscubal 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 DURATION); public void Sleep(int DURATION); } public static void main(String[] args) { Kernel32 lib =

How can i get a printer's make and model in Java?

孤者浪人 提交于 2019-11-28 07:16:39
问题 I'm actually working on a Java application that shares printers to a server, and I need this application to get the make and model of the printers it shares. I know this question has been asked three or four times but nobody seems to have found an answer. I've tried this code : PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null, null); for (PrintService printer : printServices){ System.out.println(printer.getDefaultAttributeValue(PrinterMakeAndModel.class)); System.out

Sending a Keyboard Input with Java JNA and SendInput()

瘦欲@ 提交于 2019-11-28 06:35:15
问题 I'm interested in interacting with the OS with java in this case windows 7 and want to emulate some keystrokes (e.g. CTRL + V) on a low level. First of all i know java is a bad choice but its my best programming language and i know its possible. Additionally i know awt.robot exists but its too high level for me (i really need the driver level). I'm asking this question because I really want to understand jna and after watching 20 code examples im still having problems. A code example for a

How to call a method in DLL in a Java program

守給你的承諾、 提交于 2019-11-28 04:22:40
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. Rahul Tripathi From the source : package jnahelloworldtest; import com.sun.jna.Library; import com.sun.jna.Native; import com.sun.jna.NativeLong; import com.sun.jna.Platform; import com.sun.jna.*; /** Simple example of native library declaration and usage.

How to call external dll function from java code

我的梦境 提交于 2019-11-28 00:05:20
I need to call external DLL library function from Java code. I use Netbeans 7.2. My dll's functions are: Boolean isValid(string word) List<String> getWords(String word) I'm following this example. But I don't know how declare my dll functions. And I found another link . But it doesn't work for me. I stumbled upon the same problem of "calling DLL from Java" and first was frustrated about the complexity. Yet, there is an elegant solution (might also be interesting for the people over there in the processing.org habitat..) Given the rather "general" form of the question (maybe, downrating is not

Java - Window Image

安稳与你 提交于 2019-11-27 20:54:05
Does anyone know how to capture a screen shot in Java (not it's own screen, but any other window on the desktop and they don't necessarily have to be the active window) in Windows? There are a number of threads here on this similar subject, but I have yet to find an answer. I've tried using JNA, but became stuck after a few attempts. For example... public class Main { public static void main(String[] args) { Main m = new Main(); List<WindowInfo> list = m.getWindows(); for (int i=0;i<list.size();i++) { WindowInfo info = list.get(i); System.out.println(info.getTitle()); } WindowInfo wi = list

JNA/ByteBuffer not getting freed and causing C heap to run out of memory

允我心安 提交于 2019-11-27 19:32:00
Let me start by saying that my understanding of how JNA and Java direct native memory allocations is visceral at best, so I'm trying to describe my understanding of what's going on. Any corrections in addition to responses would be great... I'm running an application that mixes Java and C native code using JNA and am running accross a reproducible issue with the Java Garbage Collector failing to free references to direct native memory allocations, resulting in the C heap running out of memory. I'm positive that my C application is not the source of the allocation issue, as I'm passing a java

How to use fingerprint sdk in java? Is there universal sdk for all fingerprint devices?

旧街凉风 提交于 2019-11-27 19:27:40
问题 I`m developing human resources software. I need to check attendence of employees. We have ZKSoftware F702-s fingerprint device. And I need get information from it in java project. I searched for sdk and documentation how to use this sdk but I did not find anything. Help me whith my project. What can I do? 回答1: I found dynamic libraries of my fingerprint device which activex component and I resolved my problem with JACOB is a JAVA-COM Bridge that allows you to call COM Automation components

How can I get the window handle (hWnd) for a Stage in JavaFX?

本小妞迷上赌 提交于 2019-11-27 19:02:58
问题 We're building a JavaFX application in Windows, and we want to be able to do some things to manipulate how our application appears in the Windows 7/8 taskbar. This requires modifying a Windows variable called the "Application User Model ID". We've already managed to do exactly what we want in Swing by using JNA, and we'd like to repeat our solution in JavaFX. Unfortunately, to do this, we need to be able to retrieve the hWnd (window handle) for each window in our application. This can be done