jna

How to pass wide strings in Java calling the MessageBoxW function in user32 lib

微笑、不失礼 提交于 2021-01-28 04:34:05
问题 I am currently struggling to use the function MessageBoxW in Java. I have managed to successfully call the user32 library and use the MessageBoxA function. Here's my code below: package messagebox; import com.sun.jna.Library; import com.sun.jna.Native; public class MessageBox { public interface user32 extends Library { public int MessageBoxA(int something, String text, String caption, int flags); } public static void main(String[] args) { System.out.println("Program starting... Library

Windows CredEnumerate in JNA

不羁的心 提交于 2021-01-28 03:51:46
问题 I am trying to use JNA to read credentials stored in Windows Credential Manager (Control Panel > Credential Manager). Found the c function for it (CredEnumerateW) which seems to run ok as it returns "true" and I am able to get the number of credentials stored in the Credential Manager (pCount.getValue() in my code). The problem is I do not know how to read the credentials data. The structure which holds the credentials(_CREDENTIAL) contains other 2 structures inside (FILETIME and CREDENTIAL

Java + JNA : The specified procedure could not be found

时光怂恿深爱的人放手 提交于 2021-01-27 15:51:16
问题 I'm trying to create a dll file using visual studio and use/access it in a java project. The library seems to get loaded, but always the same exception is thrown: Exception in thread "main" java.lang.UnsatisfiedLinkError: Error looking up function 'function': The specified procedure could not be found. My C/C++ skills ar not the best so the problem could be there. I tried to edit h and cpp files, using classes, namespaces, static methods and other staff found on the web, but nothing to do. I

Java + JNA : The specified procedure could not be found

馋奶兔 提交于 2021-01-27 15:19:21
问题 I'm trying to create a dll file using visual studio and use/access it in a java project. The library seems to get loaded, but always the same exception is thrown: Exception in thread "main" java.lang.UnsatisfiedLinkError: Error looking up function 'function': The specified procedure could not be found. My C/C++ skills ar not the best so the problem could be there. I tried to edit h and cpp files, using classes, namespaces, static methods and other staff found on the web, but nothing to do. I

Java (Windows) - By process id, get memory usage, disk usage, network usage

强颜欢笑 提交于 2021-01-27 09:36:36
问题 I've been investigating the best approach to achieve the following data for a specific process: CPU usage Memory usage Disk usage Network usage I decided to go with OSHI (Operating system & hardware information) API. Unfortunate for me , this API isn't giving me the desired info out of the box, it requires some basic knowledge of how to calculate , for example the cpu usage per process. My Question is: How can I get the memory, disk, network usage by process id ? using the following example

Java (Windows) - By process id, get memory usage, disk usage, network usage

你。 提交于 2021-01-27 09:34:11
问题 I've been investigating the best approach to achieve the following data for a specific process: CPU usage Memory usage Disk usage Network usage I decided to go with OSHI (Operating system & hardware information) API. Unfortunate for me , this API isn't giving me the desired info out of the box, it requires some basic knowledge of how to calculate , for example the cpu usage per process. My Question is: How can I get the memory, disk, network usage by process id ? using the following example

JNA How to populate a pointer-to-structure field within a structure to be PASSED to the native library?

喜你入骨 提交于 2021-01-04 06:47:06
问题 I need to pass a JNA structure to the native layer that contains a pointer-to-structure field (may contain zero-or-more structures). Here is the 'parent' structure: public class VkRenderPassCreateInfo extends Structure { public int attachmentCount; public VkAttachmentDescription.ByReference pAttachments; } (Other fields, @FieldOrder and ByReference/Value classes omitted for brevity) And here is the 'child' structure: public class VkAttachmentDescription extends Structure { public int flags; /

JNA How to populate a pointer-to-structure field within a structure to be PASSED to the native library?

こ雲淡風輕ζ 提交于 2021-01-04 06:46:56
问题 I need to pass a JNA structure to the native layer that contains a pointer-to-structure field (may contain zero-or-more structures). Here is the 'parent' structure: public class VkRenderPassCreateInfo extends Structure { public int attachmentCount; public VkAttachmentDescription.ByReference pAttachments; } (Other fields, @FieldOrder and ByReference/Value classes omitted for brevity) And here is the 'child' structure: public class VkAttachmentDescription extends Structure { public int flags; /

Unable to load JNA native support library Elasticsearch 6.x

余生颓废 提交于 2020-12-22 06:59:12
问题 I have installed Elasticsearch 6.x in my Debian 7 (wheezy) . I tried to start with service elasticsearch start but its give me an error message root@debian:~# sudo -i service elasticsearch start [FAIL] Starting Elasticsearch Server: failed! I tried to look at the elasticsearch log files at nano /var/log/elasticsearch/elasticsearch.log , and i got this error [2017-12-14T11:25:39,153][WARN ][o.e.b.Natives ] unable to load JNA native support library, native methods will be disabled. java.lang

Java(JNA)调用C++动态库(dll)

北城余情 提交于 2020-12-14 07:03:31
JNA(Java Native Access):是建立在JNI之上的Java开源框架,SUN主导开发,用来调用C、C++代码,尤其是底层的库文件(windows中叫dll文件,linux下是.so文件)。 先注意几个问题: 1.下载jna.jar包,jna-platform.jar 可以不要,但是有的话对代码的调试是有帮助的;platform.jar对于jna.jar是一种补充和扩展,jna.jar相当于核,platfrorm.jar相当于增量插件。 2.动态链接库编译时的平台。如果是通过x86平台编译,那么就只能使用32位的jdk环境加载,如果是64位jdk就必须使用x64平台编译动态库;不然,即使后面编码,动态链接库的路径都没有问题,调用还是会报错。 3.调用时多注意dll的位置。 代码开始: 对于Java来说,一般都是调用已经生成好的dll动态库。所以LZ并没有贴动态库的生成。若需要,百度一下即可。 public class JNATestDll { public interface Dll extends Library{ Dll instance = (Dll) Native.loadLibrary("HidComm", Dll. class ); public boolean LoadHidComm(); public boolean HidWriteData