jna

“ The crash happened outside the Java Virtual Machine in native code.”how to solve this error (Java)?

时光总嘲笑我的痴心妄想 提交于 2019-12-06 02:29:26
Using the library in this link http://www.blog.kslemb.com/doku.php/en/projects/globx/java_hid I have been modfied this code to write on a HID terminal if (HIDHandle.equals(WinBase.INVALID_HANDLE_VALUE)) { return HID_DEVICE_NOT_OPENED; } /* Write Feature report */ boolean Status=Kernel32.INSTANCE.WriteFile(HIDHandle, buffer, (int)buffersize, null, null); if (Status == false) { debug("Write File: " + getSystemError(Kernel32.INSTANCE.GetLastError())); return HID_DEVICE_TRANSFER_FAILED; } else { return HID_DEVICE_SUCCESS; } This code would successfully writes on the HID device but then it would

Java (JNA) - can't find function in DLL (C++) library

♀尐吖头ヾ 提交于 2019-12-06 02:08:36
I am new in Java, searched for this question in google and stackoverflow, found some posts, but still I can't understand. I want to use DLL libary (C++) methods from Java. I use JNA for this purpose. JNA found my library but it can't find my method: Exception in thread "main" java.lang.UnsatisfiedLinkError: Error looking up function 'LoadCurrentData': The specified procedure could not be found. My code: package javaapplication1; import com.sun.jna.Library; import com.sun.jna.Native; import com.sun.jna.Platform; import com.sun.jna.Pointer; public class JavaApplication1 { public interface LibPro

Java + JNA, looking for a way to run ShellExecuteW

狂风中的少年 提交于 2019-12-06 00:03:12
I am trying to run a ShellExecute function from java with JNA. I dont have any problems running ShellExecuteA on non-unicode folders import com.sun.jna.*; import com.sun.jna.platform.win32.ShellAPI; import com.sun.jna.platform.win32.WinDef; import com.sun.jna.win32.*; public class Main { public interface Shell32 extends ShellAPI, StdCallLibrary { Shell32 INSTANCE = (Shell32)Native.loadLibrary("shell32", Shell32.class); WinDef.HINSTANCE ShellExecuteA(WinDef.HWND hwnd, String lpOperation, String lpFile, String lpParameters, String lpDirectory, int nShowCmd); } public static void main(String[]

Java JNA sendMessage() not found

Deadly 提交于 2019-12-05 21:40:31
I'm trying to use JNA (Overview) to send messages to an application when minimized or not on top (mouse click for example), and the I found that people are using com.sun.jna.platform.win32.User32. SendMessage A( hW, 0x0201, 0, 0); But i can't found this function in this class. Can someone give me an example of how to implement it if I'm doing it wrong? CODE: User32 user32; Pointer hW = user32.GetForegroundWindow().getPointer(); user32.SendMessageA( hW, 0x0201, 0, 0 ); gredezcici public interface User32Ext extends User32 { User32Ext USER32EXT = (User32Ext) Native.loadLibrary("user32", User32Ext

PointerByReference not returning value

人盡茶涼 提交于 2019-12-05 20:20:25
I'm trying to call a C++ function from Java via JNA. I want to pass in a string, and get a string back. This is done by using an in parameter and an out parameter. I use PointerByReference to represent the char** out parameter. The call to C++ works, but the PointerByReference is null after the call. I based my code on the PointerByReference docs. Any ideas what I'm doing wrong? I've added print statements to the C++ to make sure it's not not setting the pointer to null, and it's definitely not. So some in my use of JNA must be wrong. But what? C++ code void processRequest(char* input, char**

Determine whether a file is a junction (in Windows) or not?

谁说胖子不能爱 提交于 2019-12-05 18:19:28
问题 I've been searching around trying to find a way to determine if a file is a junction or not, and have not found any satisfactory answers. First thing I tried was: Files.isSymbolicLink(aPath) It detects only symbolic links not the files referred to as junctions in Windows. Also tried the solution proposed here (using JNA library): Stackoverflow question (3249117) , but it never returned true on any of the files I know to be junctions. The only way I've found to determine which files are

Java library for Windows VHD API

爱⌒轻易说出口 提交于 2019-12-05 15:39:50
I need to mount and navigate a Windows VHD from Java. Anyone know of a Java library that wraps the Windows Virtual Hard Drive API or is there perhaps source code that uses JNA that I can look at. My google searches did not give me much. Even some sample code on how to convert the OpenVirtualDisk function to JNA structures would give me enough to do the rest I believe. The VHD APIs are on MSDN. Here is a link to one of the APIs. http://msdn.microsoft.com/en-us/library/windows/desktop/dd323692(v=vs.85).aspx Here is a JNA usage example to load the VHD library with JNA (adjust/define types as

Pass InputStream through JNA to C code as a File Pointer

▼魔方 西西 提交于 2019-12-05 15:01:45
I've got a DLL written in C (that I can't edit) that has some function prototype that looks like #include <stdio.h> void foo(FILE *bar); I'd like to create a JNA interface to the DLL and it's unclear what I need to pass for the FILE *bar argument. I assume I need to pass an InputStream (which is my preference), but the JNA literature seems sparse on the subject. What would the Java interface look like? and what do I really need to pass to foo? Edit: foo assumes bar is the result of an fopen and calls operations like fscanf. Edit 2: Ultimately, I have a string in Java that I need to read in C

Create a native Windows window in JNA and some GetWindowLong with GWL_WNDPROC

半城伤御伤魂 提交于 2019-12-05 14:18:57
Good day, I have been using JNA for a while to interact with the Windows API and now I am stuck when creating a window. As far as I have done the following: 1. Have created a child window of an existing window and obtained a valid handler to it. 2. Understood that every window in Windows has a non-stop message-dispatch loop. 3. Understood that the best way to include my window in the message-dispatch loop is to use something like the following code (not mine, but that is what I would do as well): final LONG_PTR prevWndProc = new LONG_PTR(User32.INSTANCE.GetWindowLong(hwnd, User32.GWL_WNDPROC))

jna getDesktop bringWindowToTop

我的梦境 提交于 2019-12-05 14:13:10
I'm having problems activating desktop window. I have taken the following approach 1: GetDesktopWindow to retrieve the handle of desktop (This works) I have tried the following methods to bring desktop window to top, but they did not work. SetForegroundWindow SwitchToThisWindow ShowWindow BringWindowToTop Is there something i'm doing wrong? Or is not possible to show desktop with jna? Hovercraft Full Of Eels One way is to do get the taskbar's handle and send it a message to hide all windows, perhaps something like this which has worked for me on Windows 7: import com.sun.jna.Native; import com