jna

Passing array from java to dll function with JNA

为君一笑 提交于 2021-02-19 07:21:29
问题 I want to pass Java array as parameter to c dll throw JNA , here is my code : import com.sun.jna.*; public class Javatest { public interface CLibrary extends Library { CLibrary INSTANCE = (CLibrary) Native.loadLibrary( "test", CLibrary.class); void test(Pointer p,int width); } public static void main(String[] args) { Pointer p = new Memory(5*Native.getNativeSize(Double.TYPE)); for (int i = 0; i < 5; i++) { p.setDouble(i*Native.getNativeSize(Double.TYPE),5); } CLibrary.INSTANCE.test(p,5); } }

android studio运行卡慢的解决方案

别说谁变了你拦得住时间么 提交于 2021-02-18 18:29:48
androidstudio安装目录下 bin/studio64.exe.vmoptions 文件:配置文件 将参数调大,比如。 -Xms2048m -Xmx2048m -XX:MaxPermSize=2048m -XX:ReservedCodeCacheSize=1024m -XX:+UseConcMarkSweepGC -XX:SoftRefLRUPolicyMSPerMB=50 -da -Djna.nosys=true -Djna.boot.library.path= -Djna.debug_load=true -Djna.debug_load.jna=true -Dsun.io.useCanonCaches=false -Djava.net.preferIPv4Stack=true -Didea.paths.selector=AndroidStudio2.2 -Didea.platform.prefix=AndroidStudio -Didea.jre.check=true 来源: oschina 链接: https://my.oschina.net/u/3980622/blog/2243773

Is it possible to use JNA/JNI to access native COM/DirectX API methods?

女生的网名这么多〃 提交于 2021-02-08 07:38:33
问题 I'm trying to call this native Windows method using JNA: HRESULT WINAPI DirectSoundCreate(LPGUID lpGuid, LPDIRECTSOUND* ppDS, LPUNKNOWN pUnkOuter ); But I'm really struggling with understanding what I should use as parameters on the Java side of things. With JNA you're supposed to create Java classes matching the native C structs, and I have done so succesfully with other parts of the WinAPI. From what I've (I think) understood so far the LPDIRECTSOUND is a typedef to a "Long pointer to a

Start/Stop services using JNA

风流意气都作罢 提交于 2021-02-06 11:09:48
问题 I am writing a utility to start and stop windows services. The program will be distributed across many computers with differing levels of user privileges so I don't want to use the command line. I've tried using JNA, import com.sun.jna.platform.win32.W32Service; import com.sun.jna.platform.win32.W32ServiceManager; import com.sun.jna.platform.win32.Winsvc; /** * * @author */ public class WindowsServices { /** * @param args the command line arguments */ public static void main(String[] args) {

Start/Stop services using JNA

放肆的年华 提交于 2021-02-06 11:07:26
问题 I am writing a utility to start and stop windows services. The program will be distributed across many computers with differing levels of user privileges so I don't want to use the command line. I've tried using JNA, import com.sun.jna.platform.win32.W32Service; import com.sun.jna.platform.win32.W32ServiceManager; import com.sun.jna.platform.win32.Winsvc; /** * * @author */ public class WindowsServices { /** * @param args the command line arguments */ public static void main(String[] args) {

Take foreground application screenshot in Windows using Java without extra edges

南楼画角 提交于 2021-02-05 08:19:26
问题 I am able to take screenshot of foreground image using below code void startScreencapture(){ RECT dimensionsOfWindow = new RECT(); User32.INSTANCE.GetWindowRect(User32.INSTANCE.GetForegroundWindow(), dimensionsOfWindow );//now in the dimensionsOfWindow you have the dimensions Robot robot = new Robot(); buf = robot.createScreenCapture( dimensionsOfWindow.toRectangle() ); } public interface User32 extends StdCallLibrary { User32 INSTANCE = (User32) Native.loadLibrary("user32", User32.class);

JNA / WinAPI. Simulate mouse click without moving the cursor doesn't work correctly

两盒软妹~` 提交于 2021-02-05 07:49:28
问题 EDIT : Sorry, but I am not sure that my questions was closed correcltly. I was suggested this thread but it doesn't answer on my question. I am able to simulate mouse click but it doesn't work correctly as I described in my question. I am still learning JNA and using it in my Java application (JNA 5.6.0 and jna-platform 5.6.0) but I hope people who familiar with C languages can understand me too because JNA is using WinAPI functions. My OS is Windows 10. What I have: Swing application that

JNA Convert HICON to Java Image

房东的猫 提交于 2021-01-29 09:56:16
问题 I knwo there is already an question like this. But its solution was not suitable for me because with the Sehellfolder Methode you can only get 16x16 and 32x32 sized icons. I have extracted a HICO with size of 256x256 and want to convert it into and Java Image like BufferedImage. I found and method for it to. But it does not work properly: public static BufferedImage getIcon(final WinDef.HICON hIcon,int ICON_SIZE,short ICON_DEPTH,int ICON_BYTE_SIZE) { final int width = ICON_SIZE; final int

Why does Kernel32 OpenProcess function return null?

两盒软妹~` 提交于 2021-01-28 19:37:18
问题 I'm trying to make an application that reads the memory of another (non-Java & 32bit) application using JNA. So far I know how to find process ID and base address of modules. And right before reading memory I need to open process and the OpenProcess function simply returns null. Also, I'm using Windows 10. // process id (pid) is known final int PROCESS_VM_READ=0x0010; final int PROCESS_QUERY_INFORMATION=0x0400; WinNT.HANDLE processHandle = Kernel32.INSTANCE.OpenProcess(PROCESS_VM_READ |

Java JNA - Base Address Finding

不问归期 提交于 2021-01-28 10:59:06
问题 I am currently attempting to read/write to memory through the use of JNA for Java. For the past week I have tried a multitude of solutions, mostly from similar projects I have found online, but nothing has resolved my problem. I know I am receiving the correct process ID of the program, then I create a Pointer using the openProcess method. Then I call getBaseAddress using the newly created Pointer. The problem I believe lies within the EnumProcessModules/Psapi method/class. Truthfully I am