
java 用jna调用delphi写的dll
java用jna调用delphi写的dlldll有某个方法functionpos_openaddr(ip_addr:string):boolean;stdcall;功能:...
java 用jna调用delphi写的dll
dll有某个方法
function pos_openaddr(ip_addr:string):boolean;stdcall;
功能:打开ip地址连接
参数:Ip_addr:ip 地址
java写法:
dll已经放入system32目录下。
public interface POSDLL extends StdCallLibrary {
public POSDLL instance = (POSDLL) Native.loadLibrary("POSDLL", POSDLL.class);
boolean pos_openaddr(String ipAddr);
}
客户端代码:
String ipAddr = "192.168.0.2";
POSDLL dll = POSDLL.instance;
dll.pos_openaddr(ipAddr);
总是报JVM错误
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x035e28e5, pid=7792, tid=6828
#
# JRE version: 6.0_35-b10
# Java VM: Java HotSpot(TM) Client VM (20.10-b01 mixed mode, sharing windows-x86 )
# Problematic frame:
# C [POSDLL.DLL+0x28e5]
#
# An error report file with more information is saved as:
# E:\workspace\*\hs_err_pid7792.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
是参数类型匹配不对,还是jvm要设置? 展开
dll有某个方法
function pos_openaddr(ip_addr:string):boolean;stdcall;
功能:打开ip地址连接
参数:Ip_addr:ip 地址
java写法:
dll已经放入system32目录下。
public interface POSDLL extends StdCallLibrary {
public POSDLL instance = (POSDLL) Native.loadLibrary("POSDLL", POSDLL.class);
boolean pos_openaddr(String ipAddr);
}
客户端代码:
String ipAddr = "192.168.0.2";
POSDLL dll = POSDLL.instance;
dll.pos_openaddr(ipAddr);
总是报JVM错误
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x035e28e5, pid=7792, tid=6828
#
# JRE version: 6.0_35-b10
# Java VM: Java HotSpot(TM) Client VM (20.10-b01 mixed mode, sharing windows-x86 )
# Problematic frame:
# C [POSDLL.DLL+0x28e5]
#
# An error report file with more information is saved as:
# E:\workspace\*\hs_err_pid7792.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
是参数类型匹配不对,还是jvm要设置? 展开
2个回答
展开全部
参考答案 儿童有无抱负,这无关紧要,可成年人则不可胸无大志
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
应该是string类型的问题,delphi的dll的参数用widestring试试。
追问
delphi比如 test.dll里有个方法比如是
function func1(var arg1:string):boolean;stdcall;
jna的接口里怎么定义这个方法?
public interface TESTDLL extends StdCallLibrary {
public TESTDLL instance = (TESTDLL ) Native.loadLibrary("test", TESTDLL .class);
public boolean func1(???);
}
就是这个问号里的参数要如何写,delphi中var说明是引用
追答
应该是delphi dll的问题,你把func1的参数arg1的类型改成widestring型。
function func1(var arg1:widestring):boolean;stdcall;
java用string型。
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询