jna

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

本秂侑毒 提交于 2019-12-07 16:34:25
问题 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

PointerByReference not returning value

浪尽此生 提交于 2019-12-07 15:27:05
问题 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

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

旧城冷巷雨未停 提交于 2019-12-07 15:20:18
问题 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 {

Java library for Windows VHD API

一笑奈何 提交于 2019-12-07 11:39:05
问题 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. 回答1: The VHD APIs are on MSDN. Here is a link to one of the APIs. http://msdn.microsoft.com/en-us/library/windows/desktop

jna getDesktop bringWindowToTop

馋奶兔 提交于 2019-12-07 10:54:15
问题 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? 回答1: One way is to do get the taskbar's handle and send it a message to hide all windows, perhaps something

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

女生的网名这么多〃 提交于 2019-12-07 09:01:03
问题 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

loading a delphi dll in java using jna

吃可爱长大的小学妹 提交于 2019-12-07 08:00:37
问题 I'm a java newbie and I'm trying to load a delphi dll, and call functions from it. Already tried in php using winbinder but it seems to be useless: reloading dll in winbinder (php gui) crashes program Anyway I have this simple java code, and I can't figure out how to make it work. There are some examples over the internet, but none seems to be working for me. Dll is 32bit, so is my windows, jdk and Eclipse. Simples function to use would be GetDllVersion . I would really apriciate any help. I

Mouse click with JNA

只愿长相守 提交于 2019-12-07 05:45:17
问题 I'm trying to simulate mouse click at window with JNA. public class App { public static final int WM_LBUTTONUP = 514; public static final int WM_LBUTTONDOWN = 513; public static final int WM_LBUTTONDBLCLK = 0x203; static int WM_CLOSE = 0x10; final static String winTitle = "Untitled - Notepad"; public static void main(String[] args) throws InterruptedException { User32Extra user32 = (User32Extra) Native.loadLibrary("user32", User32Extra.class, W32APIOptions.DEFAULT_OPTIONS); WinDef.HWND hwnd =

Calling GetOpenFileName through JNA fails for Swing app

喜夏-厌秋 提交于 2019-12-07 05:04:39
问题 I'm trying to use the native Windows file dialog in Java, using JNA to call the comdlg32 function GetOpenFileName . I've made a static method, OpenFileDialog.display that looks like this: public static List<File> display(Window parent, boolean allowMultiSelect) It should return the selected files, or null if the user canceled the dialog. I have two simple test programs. This one works as expected: package nativedialogs; import java.io.File; import java.util.List; public class SimpleTest {

What is the easiest way to call a Windows kernel function from Java?

和自甴很熟 提交于 2019-12-07 01:48:43
问题 While searching for how to do this, I found some vague discussion about different options, like JNI vs JNA, but not much in the way of concrete examples. Context: if Java's File.renameTo() cannot do it's job (for whatever reason; it is a little problematic), I'd like to fall back to directly using this native Windows function, which is defined in kernel32.dll (from this answer): BOOL WINAPI MoveFile( __in LPCTSTR lpExistingFileName, __in LPCTSTR lpNewFileName ); So, using whatever approach,