【发布时间】:2014-05-18 14:21:35
【问题描述】:
我正在尝试通过将字符串从 VFP 传递到 Delphi 的 DLL 来使用 Visual FoxPro 9 中的 Delphi 的 DLL。一旦我运行 VFP 代码,Foxpro 就会崩溃。我的字符串值小于 254 个字符。
在 delphi 的代码中包含 ShareMem 没有任何区别。似乎使用了错误的字符串类型,我真的不知道要编码的其他类型的字符串。
请帮我举例说明如何传递字符串。
dll 代码在 Delphi 中运行良好。
在 delphi 的 DLL 中...
library dll_examp_With_PARA;
uses
ShareMem,
SysUtils,
Classes,
Dialogs;
{$R *.res}
function showValues(var a:shortstring):shortstring; stdcall; export;
begin
Result:=('you passed ' + a);
end;
exports showValues;
end.
在 VFP 中.....
CLEAR ALL
LOCAL vfpString as String
DECLARE STRING showValues IN dll_examp_With_PARA.dll STRING
vfpString = 'Hello World!'
? showValues(vfpString)
CLEAR ALL
【问题讨论】:
-
如果你的项目被非 Delphi 编写的东西使用,你不能使用
ShareMem。从理论上讲,您的 Delphi DLL,尽管有一件事,应该没问题,假设这符合 VFP 的要求(我不知道)。也许这就是您在 VFP 项目中声明这一点的方式?例如,我在该声明中看不到任何类型的stdcall。 -
@jerry Vfp DECLARE 使用标准调用
标签: delphi dll visual-foxpro