package com.calldll.main;
import com.calldll.vo.Char32msg;
import com.calldll.vo.Rect;
import com.calldll.vo.SerialNum;
import com.calldll.vo.Staff;
import com.sun.jna.*;
import com.sun.jna.ptr.FloatByReference;
import com.sun.jna.ptr.IntByReference;
public class JavaDll
{
//简单回调接口
public static interface CustumPlus extends Callback {
public abstract int callback(int a, int b);
}
//简单回调实现
public static class SimpleAdd implements CustumPlus{
public final int callback(int a, int b){
return a+b;
}
}
//复杂回调接口
public static interface OnAssignSN extends Callback {
public abstract int callback(SerialNum.ByReference pSN, int nCount);
}
//复杂回调接口实现
public static class DispLastSN implements OnAssignSN{
public final int callback(SerialNum.ByReference pSN, int nCount)
{
if(nCount <=0)
return 0;
System.out.println("回调显示:");
SerialNum.ByReference [] sns = (SerialNum.ByReference[])pSN.toArray(nCount);
for(int i=0; i<nCount; i++){
System.out.println(sns[i].getMsg());
}
return nCount;
}
}
//包含复杂回调接口的结构
public static class AssignMethod extends Structure{
public String title;
public OnAssignSN fp;
public static class ByReference extends AssignMethod implements Structure.ByReference {};
}
// public interface TestDll extends Library{
// TestDll INSTANCE = (TestDll)Native.loadLibrary("fft", TestDll.class);
// void IntFcn(float[] acc, float[] t,
// float sf, float flag,
// Emx.ByReference emx, float[] velint, FFTOut[] fftout);
// void test();
// }
//动态库类
public interface DllInterface extends Library
{
DllInterface INSTANCE = (DllInterface)Native.load("DllTest", DllInterface.class);
public void DispInfor();
public void DispMessage(String msg);
public int Plus(int a, int b);
public void LoadData(IntByReference n, FloatByReference f);
// public void AssignSN(SerialNum.ByReference struct);
public void AssignSN(SerialNum struct);
public int RectangleArea(Rect.ByValue struct);
public void Standardrize(Rect.ByReference struct);
// public void Standardrize(Rect struct);
public void EnlargeRect(Rect struct);
public int MultiOperate(CustumPlus fp, int a, int b);
public int ArrayInput(SerialNum[] strt, int a);
public SerialNum ArrayOutput(IntByReference pcount);
public void FreeArray(SerialNum[] pSN);
public void CharArrayInput(Char32msg[] pChar32, int count);
public void GetStaff(Staff.ByReference staff);
public void FreeMemory(Pointer p);
public int AssignSNWithCallBack(OnAssignSN disp);
public int AppointAssignMethod(AssignMethod method);
}
public static void main(String[] args)
{
// TestDll.INSTANCE.test();
// StringBuffer sb = new StringBuffer();
// sb.append("-200,-150,-57,26,142,255,346,411,438,426,351,268,139,2,-97,-179,-215,-197,-121,-46,51,154,262,358,411,435,425,348,239,113,-11,-121,-183,-205,-189,-120,-40,59,182,291,372,421,431,407,336,230,87,-25,-134,-197,-207,-185,-174,-98,-9,109,221,334,389,443,442,374,283,185,49,-75,-152,-202,-207,-171,-76,21,130,251,342,406,431,421,351,275,146,6,-90,-174,-203,-200,-148,-58,29,147,276,362,412,437,425,349,245,122,0,-105,-181,-205,-200,-129,-39,48,170,286,371,415,425,412,348,231,107,-15,-115,-185,-211,-189,-109,-37,10,117,231,342,398,432,430,366,276,173,34,-95,-162,-203,-201,-159,-74,23,135,252,351,399,431,421,360,274,151,21,-92,-159,-209,-202,-145,-61,31,151,263,371,418,439,419,350,253,132,9,-103,-182,-204,-193,-122,-39,41,101,219,322,390,431,437,382,311,197,65,-69,-147,-193,-199,-165,-84,15,112,238,337,405,434,439,370,283,179,40,-77,-155,-201,-203,-152,-75,24,130,249,347,406,423,426,353,274,161,26,-94,-178,-203,-199,-148,-57,27,148,175,294,373,421,438,415,342,232,115,-24,-127,-187,-205,-181,-102,-28,79,203,330,404,437,435,378,301,194,62,-53,-155,-200,-200,-158,-98,4,115,241,338,400,437,438,367,278,181,37,-85,-160,-198,-198,-158,-73,28,131,261,352,404,442,422,351,273,156,20,-83,-175,-204,-194,-140,-52,32,149,274,364,388,429,440,389,312,210,79,-49,-139,-193,-212,-179,-96,-13,95,224,321,394,435,422,367,290,196,53,-63,-145,-210,-213,-166,-84,1,120,240,345,404,430,422,357,275,170,24,-74,-156,-208,-211,-162,-77,14,132,254,354,411,410,437,410,330,244,120,-2,-101,-171,-211,-200,-114,-28,57,180,294,379,420,432,425,379,288,198,65,-55,-138,-191,-210,-174,-95,0,111,222,321,400,431,417,354,275,183,51,-70,-146,-209,-218,-153,-81,13,134,243,344,414,433,415,342,259,164,23,-83,-166,-211,-198,-151,-63,21,141,267,357,416,436,413,398,311,216,98,-34,-127,-193,-216,-187,-96,-15,98,215,322,413,425,424,391,294,199,75,-46,-143,-201,-205,-171,-92,-1,110,229,331,406,427,425,372,288,198,52,-60,-150,-204,-205,-156,-84,21,125,250,352,406,434,419,343,322,254,126,7,-99,-176,-200,-193,-129,-48,40,172,289,372,425,432,404,327,223,104,-31,-122,-180,-222,-185,-99,-29,74,201,311,389,434,423,386,309,204,88,-36,-127,-193,-216,-177,-96,-18,93,221,317,406,421,423,387,292,197,67,-60,-139,-206,-213,-172,-93,8,118,228,338,396,432,425,360,274,179,123,-5,-109,-182,-212,-194,-122,-36,46,183,287,372,429,436,412,333,219,112,-14,-123,-186,-221,-185,-92,-29,67,199,300,387,423,432,403,313,195,91,-38,-132,-191,-216,-181,-101,-16,102,210,318,389,429,431,400,311,204,79,50,-69,-161,-207,-210,-159,-65,26,131,253,349,403,436,427,366,268,161,16,-108,-177,-215,-205,-124,-35,57,162,279,360,411,446,421,361,252,119,-21,-111,-183,-218,-194,-103,-38,64,174,278,370,426,442,418,348,230,83,-34,-129,-185,-219,-192,-108,-26,85,190,283,357,430,454,435,343,233,72,-57,-138,-167,-207,-212,-144,-50,39,129,233,329,410,447,456,403,291,140,-2,-102,-173,-216,-216,-141,-52,47,153,249,327,411,455,459,393,281,130,-24,-116,-183,-218,-200,-115,-39,51,158,256,343,426,458,458,383,256,95,-39,-131,-183,-191,-212,-190,-97,-18,93,194,281,369,437,467,427,342,205,49,-77,-150,-204,-211,-153,-59,26,131,238,325,396,446,456,402,286,140,-5,-114,-173,-212,-206,-140,-40,34,153,246,335,413,454,455,389,284,125,-19,-116,-179,-216,-195,-120,-41,48,159,261,356,429,458,453,366,258,91,-41,-136,-188,-221,-201,-170,-83,0,119,212,307,381,440,460,411,324,179,17,-87,-166,-212,-209,-153,-66,23,118,212,309,411,451,456,401,307,162,-2,-109,-173,-204,-206,-149,-65,30,137,247,319,394,450,457,415,314,144,-16,-118,-182,-218,-205,-124,-115,-24,61,158,262,359,430,474,458,382,257,85,-55,-146,-195,-211,-189,-109,-21,2,107,208,291,375,448,478,434,346,199,23,-109,-182,-212,-211,-157,-58,18,125,227,318,387,457,487,421,313,160,2,-122,-187,-217,-203,-141,-59,34,135,239,329,417,469,471,420,297,135,-20,-126,-187,-204,-194,-123,-39,59,102,204,288,374,448,475,431,344,204,42,-82,-171,-207,-201,-162,-81,17,115,213,313,390,456,470,413,321,178,4,-103,-167,-219,-203,-142,-59,28,129,235,332,415,455,467,389,282,138,-16,-118,-187,-210,-197,-139,-48,50,157,196,271,359,416,458,439,365,233,70,-52,-134,-197,-215,-188,-96,-12,88,194,311,399,452,451,386,305,171,23,-91,-160,-205,-217,-166,-69,15,126,245,328,405,449,456,381,289,153,-3,-104,-171,-211,-202,-146,-52,32,147,258,335,415,447,451,371,262,128,-8,-114,-176,-208,-205,-124,-37,43,162,273,348,383,440,454,412,335,202,46,-71,-142,-197,-212,-174,-92,12,110,222,318,395,450,458,396,311,183,30,-77,-146,-201,-215,-166,-66,26,129,237,332,397,448,450,394,308,164,16,-99,-169,-198,-203,-150,-55,35,153,246,346,412,437,461,443,372,243,113,-30,-129,-179,-208,-193,-112,-29,75,176,279,371,436,468,429,338,209,41,-65,-151,-192,-211,-174,-97,9,119,223,313,394,436,461,396,316,194,34,-89,-155,-204,-210,-158,-76,19,128,238,325,402,451,452,384,298,169,7,-91,-173,-207,-206,-146,-58,23,134,253,338,422,463,463,437,338,227,67,-60,-146,-191,-205,-183,-117,-20,86,197,309,389,445,454,399,310,182,37,-80,-152,-205,-215,-167,-84,9,121,237,328,406,455,450,373,284,166,12,-96,-167,-201,-213,-154,-63,30,135,263,351,417,448,442,365,347,250,108,-1
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
JavaDll.rar (34个子文件)
JavaDll
pom.xml 630B
target
classes
com
calldll
main
JavaDll$CustumPlus.class 252B
JavaDll$DllInterface.class 2KB
JavaDll$DispLastSN.class 1KB
JavaDll$OnAssignSN.class 383B
JavaDll$AssignMethod$ByReference.class 525B
JavaDll$AssignMethod.class 616B
JavaDll.class 7KB
JavaDll$SimpleAdd.class 548B
util
ConvertUtil.class 1010B
vo
Char32msg.class 548B
SerialNum$ByReference.class 435B
SerialNum$ByValue.class 419B
Staff$ByReference.class 419B
Rect$ByValue.class 399B
Rect.class 442B
Staff.class 752B
Rect$ByReference.class 415B
SerialNum.class 900B
win32-x86
DllTest.dll 128KB
generated-sources
annotations
JavaDll.iml 81B
src
test
java
main
resources
win32-x86
DllTest.dll 128KB
java
com
calldll
main
JavaDll.java 41KB
util
ConvertUtil.java 749B
vo
Char32msg.java 538B
Rect.java 331B
Staff.java 442B
SerialNum.java 672B
.idea
uiDesigner.xml 9KB
misc.xml 546B
encodings.xml 219B
compiler.xml 540B
workspace.xml 4KB
inspectionProfiles
Project_Default.xml 1KB
共 34 条
- 1
chenjp111111
- 粉丝: 3
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0