jna

JNA: Library function call returns java.lang.Error: Invalid memory access

梦想与她 提交于 2020-01-14 03:34:48
问题 I am working on a java project. In my project i am using java native access(jna) to use a c library pjsip. I have successfully used some of the function. But when i try to call pj_pool_create() , i get: java.lang.Error: Invalid memory access I have searched all the related problem published on mailing list, stack overflow, github etc. But I can not get to the solution. I placed some printf in the source code of the function before compiling it. All the printf statement get printed even the

JNA:com.sun.jna.platform.win32.Win32Exception- access denied

半腔热情 提交于 2020-01-14 03:26:26
问题 I use following code to control a windows service from java program public class PostgresService2 { public static void main(String[] args) { try { W32ServiceManager serviceManager = new W32ServiceManager(); serviceManager.open(Winsvc.SERVICE_STOP); W32Service service = serviceManager.openService("DBService", Winsvc.SERVICE_ACCEPT_STOP); service.stopService(); service.close(); } catch (Exception ex) { ex.printStackTrace(); } } } This gives error on windows7 (64bit) machine com.sun.jna.platform

How can I use a DLL with JNA that does not have an interface

南楼画角 提交于 2020-01-13 20:27:30
问题 After spending a lot of time learning Python to implement a series of DLL based function into Java via Jython - I forgot to read Jython's documentation, and the lack of ctypes support rendered most of my code useless. I didn't want to use JNI I'm trying to access some functions from a pcshll32.dll, from Personal Communications using its HLLAPI. I did manage to make it work with Python with almost no problems, it was really easy to find a lot of documentation and recipes on the web. Now I

NoSuchMethodError in jna-platform

前提是你 提交于 2020-01-13 20:23:27
问题 I wanna make a new release of the application but when starting it it throws NoSuchMethodError java.lang.NoSuchMethodError: com.sun.jna.Native.load(Ljava/lang/String;Ljava/lang/Class;Ljava/util/Map;)Lcom/sun/jna/Library; at com.sun.jna.platform.win32.Shell32.<clinit>(Shell32.java:45) at com.sun.jna.platform.win32.Shell32Util.getFolderPath(Shell32Util.java:54) at com.sun.jna.platform.win32.Shell32Util.getFolderPath(Shell32Util.java:71) at com.faforever.client.preferences.PreferencesService.

JNA Struct and Pointer mapping

…衆ロ難τιáo~ 提交于 2020-01-13 09:22:27
问题 How does one map the function below to java? VOID WriteToStruct(BOOL *Status, STRUCT_MSG RecBuff) What this function does: 1) Populates the struct RecBuff 2) Updates status How do I map to a boolean pointer in Java and access the struct data updated by the function? 回答1: I was searching for another issue concerning JNA and structs, and Google redirected me here. I hope this helps. From JNA API To pass a structure by value, first define the structure, then define an empty class from that which

JNA Struct and Pointer mapping

你。 提交于 2020-01-13 09:21:52
问题 How does one map the function below to java? VOID WriteToStruct(BOOL *Status, STRUCT_MSG RecBuff) What this function does: 1) Populates the struct RecBuff 2) Updates status How do I map to a boolean pointer in Java and access the struct data updated by the function? 回答1: I was searching for another issue concerning JNA and structs, and Google redirected me here. I hope this helps. From JNA API To pass a structure by value, first define the structure, then define an empty class from that which

Disable Background drawing in JFrame in order to properly display Aero (DWM) effects

狂风中的少年 提交于 2020-01-12 03:18:09
问题 I'm having problems using the DWM functionality of Windows Vista/7 on Java windows. I want to make the background of my frame use the Aero style. The Windows API to do so is provide by the function DwmExtendFrameIntoClientArea in the dwmapi library. I've managed to call the procedure properly via JNA, and it does what it is supposed to do (You can see that for example when resizing the frame, before the next repaint you see the proper aero effects in the area not yet painted, see the attached

How can I read the window title with JNI or JNA?

南楼画角 提交于 2020-01-09 10:46:48
问题 Looking to get back into the development space; primarily using Java to call some native win32 functions (I don't desire to build in .NET).... Can someone point me to a place where I can read the title from a differnt running window using Java (JNI/JNA/SWIG). Assume you would know where in the memory space the application you are attempting to hook into is. 回答1: In JNA: public interface User32 extends StdCallLibrary { User32 INSTANCE = (User32) Native.loadLibrary("user32", User32.class); int

Working example of JNA mouse hook

随声附和 提交于 2020-01-09 02:29:24
问题 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 回答1: 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

What to use instead of LPTSTR in java JNA?

那年仲夏 提交于 2020-01-06 17:58:06
问题 I am adding User32Ext methods to JNI. In particular, I extended the original UserExt class: package sirius.core; import com.sun.jna.Native; import com.sun.jna.Pointer; import com.sun.jna.platform.win32.Kernel32; import com.sun.jna.platform.win32.WinDef; import com.sun.jna.platform.win32.WinNT; import com.sun.jna.win32.W32APIOptions; public abstract interface Kernel32Ext extends Kernel32 { public static final Kernel32Ext INSTANCE = (Kernel32Ext)Native.loadLibrary("kernel32.dll", Kernel32Ext