我试图访问delphiXE2中从python转换的DLL。在
以下是python程序的摘录:
#!/usr/local/bin/python
# -*- coding: utf-8 -*-
from ctypes import *
from os.path import dirname, join
_dir = dirname(__file__)
try:
mylib = cdll.LoadLibrary(join(_dir, "myAPI.dll"))
except:
print "myAPI.dll not loaded"
const0 = 0
const1 = 1
def libCalculation(data):
""" generic calculation fonction
"""
cr = mylib.libCalculation(c_char_p(data))
return cr
def function1(p1, p2, p3, p4, value=const1):
cr = mylib.function1(
c_double(p1), c_double(p2),
c_double(p3), c_double(p4),
c_int(value)
)
return cr
我尝试在delphi中将调用转换为function1,如下所示:
^{pr2}$在dll中正确地找到了该函数,但我得到一个执行错误: ".. 浮点堆栈检查”。在
我的换算正确吗?我能错过什么?是否有与double类型相关的内容?我试过不同类型的检查,但没有成功。。。在
libCalculation(data)函数对我来说也是个谜。如何在Delphi中转换它?在
欢迎帮忙。 谢谢你
Python代码使用
cdll
,因此调用约定是cdecl
。另外,默认情况下,ctypes
中的返回类型是c_int
,但是您使用了double
。这种不匹配解释了运行时错误。在所以德尔菲应该是:
对于另一个函数,它接受一个指向以null结尾的8位字符数组的指针,并返回整数:
^{pr2}$相关问题 更多 >
编程相关推荐