java jna 调用windows动态链接库
import com.sun.jna.Library; import com.sun.jna.Native; import com.sun.jna.Platform; import com.sun.jna.WString; public class Program { public interface user32 extends Library { public int MessageBoxW(int something, WString text, WString caption, int flags); } public static void main(String[] args) { @SuppressWarnings("deprecation") user32 lib = (user32) Native.loadLibrary("user32", user32.class); lib.MessageBoxW(0, new WString("MessageBox success!"), new WString("Attention"), 0); System.out.println("end"); } }
需引入:jna-5.4.0.jar和jna-platform-5.4.0.jar
桂棹兮兰桨,击空明兮溯流光。