我用vb调用delphi中的dll时候 遇到问题 例子如下:delphi中的函数如下: Function Listen (ListenPort:integer):boolean; stdcall; external 'JustPipe.Dll'; Function SetOnFileArrive(Const p_Port :Integer; Const p_OnFileArrive:TOnFileArrive):Boolean; stdcall; external 'JustPipe.Dll'; TOnFileArrive=Procedure(Const p_FileName:PChar):Integer; stdcall;vb中我个人写的声明及回调函数 Declare Function Listen Lib "JustPipe" (ByVal port As Integer) As Boolean Declare Function SetOnFileArrive Lib "JustPipe" (ByVal port As Integer, ByRef d As Long) As Boolean //下面函数是调用dll中的SetOnFileArrive函数 以及传递我的回调函数的地址 Public Sub Hook() Listen 2000 a = SetOnFileArrive(2000, AddressOf gcb)End Sub End Sub 回调函数如下: Public Sub gcb(ByVal filename As String) MsgBox "ok" End Sub以上哪儿出了问题 为啥调用不成功
VB里没有对应的类型,VB里字符串只有String,指针用Long型吧
是往Delphi里传参数码?就用String啊,不行用Strconv(str,vbFroimUnicode)试一下
不行就用
Any 类型
Function Listen (ListenPort:integer):boolean; stdcall; external 'JustPipe.Dll';
Function SetOnFileArrive(Const p_Port :Integer;
Const p_OnFileArrive:TOnFileArrive):Boolean; stdcall; external 'JustPipe.Dll';
TOnFileArrive=Procedure(Const p_FileName:PChar):Integer; stdcall;vb中我个人写的声明及回调函数
Declare Function Listen Lib "JustPipe" (ByVal port As Integer) As Boolean
Declare Function SetOnFileArrive Lib "JustPipe" (ByVal port As Integer, ByRef d As Long) As Boolean
//下面函数是调用dll中的SetOnFileArrive函数 以及传递我的回调函数的地址
Public Sub Hook()
Listen 2000
a = SetOnFileArrive(2000, AddressOf gcb)End Sub
End Sub
回调函数如下:
Public Sub gcb(ByVal filename As String)
MsgBox "ok"
End Sub以上哪儿出了问题 为啥调用不成功
这里应该是
SetOnFileArrive(2000, byval AddressOf gcb)
传 gcb 的地址的的值