vb中调用delphi中的dll的问题 ( 积分: 50 )

  • 主题发起人 tajingde
  • 开始时间
T

tajingde

Unregistered / Unconfirmed
GUEST, unregistred user!
我在vb中引用的delphi中的dll 并写了回调函数 以便dll来调用 运行时调用成功并弹出“ok”对话框
但忽然程序就挂啦

delphi中的函数如下

Procedure SetOnFileArrive (const p_OnFileArrive :TOnFileArrive ); stdcall; external

'JustPipe.Dll';

TOnFileArrive =Procedure(Const p_CltAddr :pChar;
Const p_CltPort :integer;
Const p_LisnPort:integer;
Const p_FName :pChar;
Const p_DestDir :pChar) Of Object;

vb中我是这样写的
首先引用声明
Declare Function SetOnFileArrive Lib "JustPipe" (ByRef b As Long) As Boolean
然后调用

SetOnFileArrive(AddressOf gcb)‘gcb是我的回调函数

Dim fillname As String
Dim port As Integer
Dim lisnport As Integer
Dim filename As String
Dim desdir As String

Public Sub gcb(fillname, port, lisnport, filename, desdir)
MsgBox “ok”
End Sub

到底问题出在那儿 是我的vb回调函数不对吗 还是delphi的问题
 
我在vb中引用的delphi中的dll 并写了回调函数 以便dll来调用 运行时调用成功并弹出“ok”对话框
但忽然程序就挂啦

delphi中的函数如下

Procedure SetOnFileArrive (const p_OnFileArrive :TOnFileArrive ); stdcall; external

'JustPipe.Dll';

TOnFileArrive =Procedure(Const p_CltAddr :pChar;
Const p_CltPort :integer;
Const p_LisnPort:integer;
Const p_FName :pChar;
Const p_DestDir :pChar) Of Object;

vb中我是这样写的
首先引用声明
Declare Function SetOnFileArrive Lib "JustPipe" (ByRef b As Long) As Boolean
然后调用

SetOnFileArrive(AddressOf gcb)‘gcb是我的回调函数

Dim fillname As String
Dim port As Integer
Dim lisnport As Integer
Dim filename As String
Dim desdir As String

Public Sub gcb(fillname, port, lisnport, filename, desdir)
MsgBox “ok”
End Sub

到底问题出在那儿 是我的vb回调函数不对吗 还是delphi的问题
 
回调函数也加上stdcall试试。
 
怎么在vb中加入 stdcall 是不是参数的问题呢
 
在Delphi里加上试试:
TOnFileArrive =Procedure(Const p_CltAddr :pChar;
Const p_CltPort :integer;
Const p_LisnPort:integer;
Const p_FName :pChar;
Const p_DestDir :pChar) Of Object; stdcall;
 

Similar threads

I
回复
0
查看
581
import
I
I
回复
0
查看
608
import
I
I
回复
0
查看
690
import
I
I
回复
0
查看
580
import
I
顶部