zoukankan      html  css  js  c++  java
  • 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".

  • 相关阅读:
    ActiveMQ学习第八篇:Consumer
    ActiveMQ学习第七篇:Messaage
    线性判别分析LDA
    逻辑回归
    那些年,曾踩过的Spark坑
    HBase表创建、删除、清空
    python的多线程
    python的多进程
    python实现读写txt文件
    python的封包和解包
  • 原文地址:https://www.cnblogs.com/xiondun/p/15781564.html
Copyright © 2011-2022 走看看