久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

向 JNA Class Java (Kernel32) 添加另一種方法

Adding another method to JNA Class Java (Kernel32)(向 JNA Class Java (Kernel32) 添加另一種方法)
本文介紹了向 JNA Class Java (Kernel32) 添加另一種方法的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我試圖使用來自 WIN32 dll 的方法,但 JNA 中沒有.

I was trying to use a method from WIN32 dll, not included in JNA.

方法是GetProductInfo

我在單獨的項目和工作中嘗試這個:

I try this in separate project and work:

  public interface Kernel32 extends Library {
    public boolean GetProductInfo(int dwOSMajorVersion,int dwOSMinorVersion,
        int dwSpMajorVersion, int dwSpMinorVersion, IntByReference pdwReturnedProductType);
  }  

使用..

    Kernel32 lib = (Kernel32) Native.loadLibrary("kernel32", Kernel32.class);
    IntByReference dwType = new IntByReference();
    lib.GetProductInfo(6,0,0,0,dwType);
    switch (dwType.getValue()) {
    // Something
    }

但我需要使用 JNA

import com.sun.jna.platform.win32.Kernel32;
import com.sun.jna.platform.win32.User32;
import com.sun.jna.platform.win32.WinBase;
import com.sun.jna.platform.win32.WinDef;
import com.sun.jna.platform.win32.WinNT;
import com.sun.jna.platform.win32.WinUser;

  public interface Kernel32 extends Library {

    Kernel32 INSTANCE = (Kernel32)Native.loadLibrary("kernel32", Kernel32.class);
    // I need to insert this method!!!
    public boolean GetProductInfo(int dwOSMajorVersion,int dwOSMinorVersion,
        int dwSpMajorVersion, int dwSpMinorVersion, IntByReference pdwReturnedProductType);

    // This snippet I think should not Needed, 
    //but if I remove this code this methods will not be recognized
    //but if I leave this code, it is not working properly!!!
    public void GetSystemInfo(WinBase.SYSTEM_INFO lpSystemInfo);
    public boolean GetVersionExA(WinNT.OSVERSIONINFOEX lpVersionInfo);
    public boolean GetVersionExA(WinNT.OSVERSIONINFO lpVersionInfo);
  }

使用代碼:

  WinNT.OSVERSIONINFOEX osviex = new WinNT.OSVERSIONINFOEX();
  WinNT.OSVERSIONINFO osvi = new WinNT.OSVERSIONINFO();
  WinBase.SYSTEM_INFO si = new WinBase.SYSTEM_INFO();
  String major = "", sub = "";
  boolean bOsVersionInfoEx = Kernel32.INSTANCE.GetVersionExA(osviex);
  boolean bOsVersionInfo = Kernel32.INSTANCE.GetVersionExA(osvi);
  Kernel32.INSTANCE.GetSystemInfo(si);

  // If I declare newly (the old methods), these will not work fine (Bad result)!!! 
  System.out.println("osviex.dwPlatformId.intValue()"+osviex.dwPlatformId.intValue());
  System.out.println("osviex.dwMajorVersion.intValue()"+osviex.dwMajorVersion.intValue());
  System.out.println("osvi.dwPlatformId.intValue()"+osvi.dwPlatformId.intValue());
  System.out.println("osvi.dwMajorVersion.intValue()"+osvi.dwMajorVersion.intValue());

我需要這個方法的結果!!!

I need the result of this method!!!

  IntByReference dwType = new IntByReference();
  Kernel32.INSTANCE.GetProductInfo(6,0,0,0,dwType);
  switch (dwType.getValue()) {
  //... code
  }

如何在 Kernerl32 中包含一個新方法(已在 JNA -> com.sun.jna.platform.win32.Kernel32 中定義)?

推薦答案

這是擴展 JNA 平臺映射定義的庫的方式:

This is how you extend a library defined by JNA's platform mappings:

public interface Kernel32 extends com.sun.jna.platform.win32.Kernel32 {
    Kernel32 INSTANCE = (Kernel32)Native.loadLibrary("kernel32", Kernel32.class, com.sun.jna.win32.W32APIOptions.DEFAULT_OPTIONS);

    boolean GetProductInfo(int dwOSMajorVersion, int dwOSMinorVersion, int dwSpMajorVersion, int dwSpMinorVersion, IntByReference pdwReturnedProductType);
}

這篇關于向 JNA Class Java (Kernel32) 添加另一種方法的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to wrap text around components in a JTextPane?(如何在 JTextPane 中的組件周圍環繞文本?)
MyBatis, how to get the auto generated key of an insert? [MySql](MyBatis,如何獲取插入的自動生成密鑰?[MySql])
Inserting to Oracle Nested Table in Java(在 Java 中插入 Oracle 嵌套表)
Java: How to insert CLOB into oracle database(Java:如何將 CLOB 插入 oracle 數據庫)
Why does Spring-data-jdbc not save my Car object?(為什么 Spring-data-jdbc 不保存我的 Car 對象?)
Use threading to process file chunk by chunk(使用線程逐塊處理文件)
主站蜘蛛池模板: 亚洲精品乱码久久久久v最新版 | 一区二区三区免费 | 午夜影院网站 | 欧美一级久久 | 亚洲精品久久久久久一区二区 | 日本欧美国产在线观看 | 欧美亚洲综合久久 | 欧美色性 | 国产精品免费大片 | 一级黄色毛片免费 | 国产精品精品久久久 | 欧美性久久 | 欧美日韩精品区 | 国产精品福利久久久 | 九九热在线视频观看这里只有精品 | 国产精品国产a级 | 一区二区手机在线 | 亚洲高清在线观看 | 日本aa毛片a级毛片免费观看 | 在线一区 | 精品日韩一区二区三区av动图 | 免费在线观看成人 | 国产视频精品区 | 国产精品亚洲成在人线 | 成人在线观看网站 | 国产精品美女久久久久久免费 | 狠狠艹 | 亚洲国产精品一区二区第一页 | 国产亚洲日本精品 | 欧美国产中文 | 久久免费视频1 | av第一页 | www.色综合| 亚洲精品免费观看 | 999国产精品视频免费 | 成人一区二 | 成人午夜在线 | 91色站| 97高清国语自产拍 | 久久在线看| 青青草一区二区 |