jna

How can I get system/hardware info via Java? [duplicate]

我的梦境 提交于 2019-11-27 18:49:35
This question already has an answer here: get OS-level system information 15 answers I need to get system and hardware info via a Java application. I'm interested in: Os details; Processors count, names, processor load in percents; Memory status (total/free); Os process (threads) count and CPU/Memory usage for each of them; Network statistic (for each interface); Is there a Java library that can do this? Rachel Using Java to get os level system Information will get you started in right direction. Finding Operating System Information How to get System Information using Java i have used SIGAR

How to map enum in JNA

佐手、 提交于 2019-11-27 18:06:16
问题 I have the following enum how do i map in jna ?? This enum is further referenced in structure. typedef enum { eFtUsbDeviceNotShared, eFtUsbDeviceSharedActive, eFtUsbDeviceSharedNotActive, eFtUsbDeviceSharedNotPlugged, eFtUsbDeviceSharedProblem } eFtUsbDeviceStatus; Abdul Khaliq 回答1: If you're using JNA you probably want to explicitly specify the values of the enumeration in Java. By default, Java's basic enum type doesn't really give you that functionality, you have to add a constructor for

Using JNA to get/set application identifier

寵の児 提交于 2019-11-27 17:32:34
Following up on my previous question concerning the Windows 7 taskbar , I would like to diagnose why Windows isn't acknowledging that my application is independent of javaw.exe . I presently have the following JNA code to obtain the AppUserModelID : public class AppIdTest { public static void main(String[] args) { NativeLibrary lib; try { lib = NativeLibrary.getInstance("shell32"); } catch (Error e) { System.err.println("Could not load Shell32 library."); return; } Object[] functionArgs = new Object[1]; String functionName = null; Function function; try { functionArgs[0] = new String("Vendor

Interface Ada dynamic Library with Java using JNA and Ada's Interface.C packages

删除回忆录丶 提交于 2019-11-27 08:28:56
问题 I have to write a DLL is supposed to provide a simple service that takes: IN a string or byte array (equivalent of char*) IN integer expliciting the size of the in char* IN equivalent of char* buffer used by library to write data in IN size of the available char* buffer for writing OUT effetive written size into the out char* buffer Using a C point of view, the signature should look like: void myService (char* inBuffer, // as in string int anInteger, // as in param char* outBuffer, // used as

Implementing Workstation lock listener using Java

让人想犯罪 __ 提交于 2019-11-27 08:21:05
问题 Window get locked when we press WIN_HOME+L key together. We can find lot good example to listen to window lock event in VB. But I am doing window lock listener for Java. I've done some research and made a listener program that listen to window lock event. It has two interface and one main program with JFrame and uses JNA library. WindowUser32.java public interface WindowUser32 extends User32 { public static final WindowUser32 MYINSTANCE = (WindowUser32) Native.loadLibrary("user32",

JNA - Query Windows Processes

天大地大妈咪最大 提交于 2019-11-27 08:12:57
问题 I'm trying to use JNA to return details on a specific Windows Process. Not exactly sure how to do this. Couldn't find much on the interwebs for help. Some information I would like returned include CPU and memory usage. The below is just an example I found. import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import com.sun.jna.*;

How to get list of all window handles in Java (Using JNA)?

醉酒当歌 提交于 2019-11-27 08:06:48
I am novice for JNA. I am trying to get handles for all the windows including minimised ones. I need HWND of all the windows. I have gone thro the question Windows: how to get a list of all visible windows? which helped me to get list of windows, but it has hWnd type as int. I can't use it with com.sun.jna.platform.win32.User32 functions which asks for hWnd of type com.sun.jna.platform.win32.WinDef.HWND . So, Is there any way to get all the window handles of type com.sun.jna.platform.win32.WinDef.HWND rather than int pointer? Finally, why is the difference int and HWND ? How does it accept

Setting up JNA in Android Studio

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 07:54:16
问题 I try to import jna.jar into my project since JNA is a very useful tool to call Native library which is base on JNI. OS: Windows 10 IDE: Android Studio 1.5.1 JDK: 1.8.0_73 NDK: r10e What I have done (AS = Android Studio) Create a new project by AS with API18. Download jna.jar from their GitHub. https://github.com/java-native-access/jna copy jna.jar into project folder. JNATest\app\libs\jna.jar In AS, right-click on the icon of jna.jar, choose Add as Library Wait for few seconds, check the

Trying to use DLL from Java (JNA). Unable to load library exception

梦想与她 提交于 2019-11-27 05:25:42
I have NetBeans project from tutorial which causes exception: Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'simpleDLL': The specified module could not be found. Tried to put simpleDLL.dll in project libraries, copied file in system32 folder with no success. BackSlash I had exactly the same problem with loading a DLL, I solved it in this way: As Christian Kuetbach said, check if the simpleDLL you are using is compatible with your processor's architecture, a 32-bit DLL won't work on a 64-bit machine, and also a 64-bit DLL won't work on a 32-bit machine. If

Working example of JNA mouse hook

半腔热情 提交于 2019-11-27 05:20:39
Can any one provide me with a working example of JNA mouse hook, which would be able to track mouse movements/click outside my Java Swing application ? Thanks in Advance baba Yep, here is the code... public class CWMouseHook { public final User32 USER32INST; public final Kernel32 KERNEL32INST; public CWMouseHook() { if(!Platform.isWindows()) { throw new UnsupportedOperationException("Not supported on this platform."); } USER32INST = User32.INSTANCE; KERNEL32INST = Kernel32.INSTANCE; mouseHook=hookTheMouse(); Native.setProtected(true); } public static LowLevelMouseProc mouseHook; public HHOOK