pb调用delphi的dll函数问题,请高手指教,谢谢!

yxs2000 2005-04-22 12:11:43
delphi的dll代码为:

FUNCTION w_set_clock(clock: pchar): integer; stdcall;
BEGIN
clock := '1234567890';
result := 1;
END;

pb的声明为:
FUNCTION long w_set_clock(Ref string clock) library "test.dll"
执行后返回结果为1正确,但是传递的参数clock是乱字符,不是'1234567890'。
请高手指点,谢谢!
...全文
257 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
31737951 2005-05-22
  • 打赏
  • 举报
回复
FUNCTION long w_set_clock(Ref blob{100} clock) library "test.dll"
hygougou 2005-05-21
  • 打赏
  • 举报
回复
还没搞定?

procedure test (Value: Integer; var Reference: Integer; out OutVar: Integer);
::
Value: 传值;只能传入数据,不能传出数据。
Reference: 传入引用,也就是变量的地址;也可不指定变量的类型;
既可传入也可传出数据变量。
OutVar: 也是传入引用,但只能传出数据,不能传入数据。

Examples:

function DoubleVal (Val: Integer) : Integer;
begin
Val := Val * 2;
Result := Val;
end;

function DoubleRef (var Val: Integer): Integer;
begin
Val := Val * 2;
Result := Val;
end;

var
I, J: Integer;
begin
I := 2;
J := DoubleVal (I); // I = 2; J = 4;
//如果调用下面的话,
// J := DoubleRef (I); // I = 4; J = 4;
---------------------------------------------------------
参考
http://search.csdn.net/Expert/topic/1429/1429928.xml?temp=.9883234

更多
http://search.csdn.net/search.asp?key=pchar%B5%F7%D3%C3&class=Delphi&size=10&option=advance&x=70&y=8
老吴子 2005-05-21
  • 打赏
  • 举报
回复
试试:
FUNCTION w_set_clock(clock: pchar): integer; stdcall;
BEGIN
StrPLCopy(clock,'1234567890',10);
result := 1;
END;
你在PB中的声明正确;
必须确保调用前有足够的空间,即用space函数
j9dai 2005-05-13
  • 打赏
  • 举报
回复
关注 + 友情UP
yxs2000 2005-05-13
  • 打赏
  • 举报
回复
难道就没有高手了吗?都没有解决问题啊!
debye 2005-04-23
  • 打赏
  • 举报
回复
哦,那到底听谁的啊。。。
yxs2000 2005-04-22
  • 打赏
  • 举报
回复
up
nimittz 2005-04-22
  • 打赏
  • 举报
回复
楼上的注意了,这个问题我见过,一定注意别加var,加了反而不行,只要直接给clock初始化就没问题了,我以前做过。
hygougou 2005-04-22
  • 打赏
  • 举报
回复
FUNCTION w_set_clock(clock: pchar): integer; stdcall;


要返回参数要加var的呀,居然能返回?奇怪


FUNCTION w_set_clock(var clock: pchar): integer; stdcall;
hornbilltofy 2005-04-22
  • 打赏
  • 举报
回复
调用前给clock付初值如space(100)了吗?

680

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder API 调用
社区管理员
  • API 调用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧