vb调用DELPHI写的动态库问题

bcwtsy 2008-04-02 04:31:53
vb调用DELPHI写的动态库问题


function MXReadFingerFromSensor(FingerBufchar):Boolean; stdcall; external 'JLZD02.DLL'\\DELPHI中的函数


VB中的代码:
Public Declare Function drjw Lib "JLZD02.DLL" Alias "MXReadFingerFromSensor" (ByVal Pchar As String) As Boolean
Private Sub Command5_Click()
dim s as string
s = String(255, vbNullChar)
If (drjw(s) = False) Then
MsgBox "读入失败!"
Else
MsgBox "读入成功!"
End If
End Sub

程序运行后,提示内存读取错误,然后自动关闭VB,问题出在哪啊,高手帮帮忙吧,弄了一天也没解决啊!!!!
...全文
95 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
bcwtsy 2008-04-04
  • 打赏
  • 举报
回复
万分感谢!!!你的方法是对的,问题终于解决了!!!!!!!!!!!!!!!!!!!!!!!!
supergreenbean 2008-04-03
  • 打赏
  • 举报
回复
原来是个二维数组,难怪呢

你这样试试

Public Declare Function drjw Lib "JLZD02.DLL" Alias "MXReadFingerFromSensor" (Pchar As Any) As Long
Private Sub Command5_Click()
dim chars(303,255) as byte
If (drjw(chars(0,0) = False) Then
MsgBox "读入失败!"
Else
MsgBox "读入成功!"
End If
End Sub
bcwtsy 2008-04-03
  • 打赏
  • 举报
回复
以上两种的方法都行不通,第一种仍然提示内存读取错误,第二种在释放设备的时候提示内存读取错误!
delphi中是这样定义的:
var
FingerBuf:Array[0..303,0..255] of char;
函数是这样的:function MXReadFingerFromSensor(FingerBuf:Pchar):Boolean; stdcall; external 'JLZD02.DLL'

哪位帮忙解决一下吧!急死我了!!!!!
supergreenbean 2008-04-02
  • 打赏
  • 举报
回复
Public Declare Function drjw Lib "JLZD02.DLL" Alias "MXReadFingerFromSensor" (ByVal Pchar As String) As Long

看下你的文档中有关Pchar缓冲区的要求。

迈克揉索芙特 2008-04-02
  • 打赏
  • 举报
回复
这样试试
If (drjw(strptr(s)) = False) Then

7,785

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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