• jna


    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>org.example</groupId>
        <artifactId>jna_test</artifactId>
        <version>1.0-SNAPSHOT</version>
        <dependencies>
            <dependency>
                <groupId>net.java.dev.jna</groupId>
                <artifactId>jna</artifactId>
                <version>5.3.1</version>
            </dependency>
        </dependencies>
    
    </project>
    public class JnaTest {
        public static void main(String[] args) {
            MsvcrtLibrary.INSTANCE.printf("Hello, World\n");
        }
    }
    import com.sun.jna.Library;
    import com.sun.jna.Native;
    
    public interface MsvcrtLibrary extends Library {
        //加载动态库
        MsvcrtLibrary INSTANCE = Native.load("msvcrt", MsvcrtLibrary.class);
    
        void printf(String format, Object... args);
    }

    Default Type Mappings

    Java primitive types (and their object equivalents) map directly to the native C type of the same size.

    Native Type Size Java Type Common Windows Types
    char 8-bit integer byte BYTE, TCHAR
    short 16-bit integer short WORD
    wchar_t 16/32-bit character char TCHAR
    int 32-bit integer int DWORD
    int boolean value boolean BOOL
    long 32/64-bit integer NativeLong LONG
    long long 64-bit integer long __int64
    float 32-bit FP float  
    double 64-bit FP double  
    char* C string String LPTCSTR
    void* pointer Pointer LPVOID, HANDLE, LPXXX

    Unsigned types use the same mappings as signed types. C enums are usually interchangeable with "int".

  • 相关阅读:
    java实现二叉树的构建以及三种遍历
    binary-tree-preorder-traversal二叉树的前序遍历
    insertion-sort-list使用插入排序对链表进行排序
    binary-tree-postorder-traversa二叉树的后序遍历
    sort-list
    Redis的数据类型
    在Windows上搭建Redis服务器
    Eureka源码分析
    Eureka概念理解
    Spring Cloud Eureka
  • 原文地址:https://www.cnblogs.com/xiondun/p/15781564.html
Copyright © 2020-2023  润新知