标题:VFP 引用DLL 显示错误
只看楼主
aroffice
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2011-9-23
结帖率:92.31%
已结贴  问题点数:20 回复次数:6 
VFP 引用DLL 显示错误
准备做一个验证码本地识别,在网上找了一些代码,但在VFP中引用显示错误
需要怎样修改
test.rar (486.53 KB)

搜索更多相关主题的帖子: 错误 引用 VFP DLL 显示 
2022-06-24 13:30
吹水佬
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:432
帖 子:10064
专家分:41463
注 册:2014-5-20
得分:14 
下载失败,test.rar 被警告有病毒
2022-06-24 14:00
aroffice
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2011-9-23
得分:0 
Private Declare Function loadcode Lib "ycode.dll" (ByVal code As Long, ByVal Length As Long, ByVal address As String, ByVal pass As String) As Long
Private Declare Function Recognition Lib "ycode.dll" (ByVal ItemNo As Long, ByVal picin As Long, ByVal Length As Long, ByVal Address1 As String, ByVal Address2 As String, lppicout As Long, lpLength As Long, cLength As Long) As Long
Private Declare Function lstrcpy Lib "kernel32" Alias "lstrcpyA" (ByVal lpString1 As String, ByVal lpString2 As Long) As Long
Private Declare Function Writepic Lib "ycode.dll" (ByVal c As String) As Long
Dim strResult As String '识别结果
Dim no1 As Long
Dim no2 As Long
Dim n1 As Long '图片指针
Dim n2 As Long '指针长度

Private Sub Form_Load()
no1 = loadcode(0, 0, "myfc.fc", "") '载入验证码库,把路径换成你的库,当然你也可以直接传递数据,返回项目个数,最后一个参数为库文件密码,如果库文件有密码,这里必须加上
End Sub

Private Sub Command1_Click()

strResult = "    " '验证码都是4个字符的先初始一个4个字节的空白字符串,对于字母长度不定的可以通过Recognition的第8个参数获取字母长度

no1 = Recognition(1, 0, 0, "http://passport., "", n1, n2, 0) '返回识别结果字符的指针,第四个参数为网络地址

no2 = lstrcpy(strResult, no1) '把识别结果放在strResult中

no2 = Writepic("c:\look.bmp")  '把获取的网络图片放在指定的路径,以用来显示,你也可以自己设置自己喜欢的保存路径。

Text1.Text = strResult

Picture1.Picture = LoadPicture("c:\look.bmp") '显示本次识别的图片

End Sub



我从别人做的识别系统内提出ycode.dll, y300xxxx.cll,yxxxx.cll 3个库文件,放到vb程序目录下,正常调用,但每当调用函数的时候就出现错误, 提示内存 ****位置不能为read。识别库没有问题,用我自己的和其他的都一样,是不是我的库文件本身有毛病?

Private Declare Function loadcode Lib "ycode.dll" (ByVal code As Long, ByVal Length As Long, ByVal address As String, ByVal pass As String) As Long
Private Declare Function Recognition Lib "ycode.dll" (ByVal ItemNo As Long, ByVal picin As Long, ByVal Length As Long, ByVal Address1 As String, ByVal Address2 As String, lppicout As Long, lpLength As Long, cLength As Long) As Long
Private Declare Function lstrcpy Lib "kernel32" Alias "lstrcpyA" (ByVal lpString1 As String, ByVal lpString2 As Long) As Long
Private Declare Function Writepic Lib "ycode.dll" (ByVal c As String) As Long
Dim noo As Long
Dim jieguo As String '识别结果
Dim no1 As Long
Dim no2 As Long
Dim n1 As Long '图片指针
Dim n2 As Long '指针长度

Private Sub Command1_Click()
'采用传递网络验证码路径方式
jieguo = " " '验证码都是4个字符的先初始一个4个字节的空白字符串,对于字母长度不定的可以通过Recognition的第8个参数获取字母长度
no1 = Recognition(1, 0, 0, "http://members.china., "", n1, n2, 0) '返回识别结果字符的指针
no2 = lstrcpy(jieguo, no1) 'VB中用lstrcpy就可以从指针得到字符了,当然你也可以选择其他的方式
no2 = Writepic("") '这行代码的目的是把图片解码成bmp图片,可选。
Text1.Text = jieguo
Picture1.Picture = LoadPicture("c:\code.bmp")

End Sub

Private Sub Command2_Click()
'采用传递本地验证码图片方式
jieguo = " " '验证码都是4个字符的先初始一个4个字节的空白字符串,对于字母长度不定的可以通过Recognition的第8个参数获取字母长度
no1 = Recognition(1, 0, 0, "", "ci.GIF", n1, n2, 0) '返回识别结果字符的指针
no2 = lstrcpy(jieguo, no1) 'VB中用lstrcpy就可以从指针得到字符了,当然你也可以选择其他的方式
no2 = Writepic("") '这行代码的目的是把图片解码成bmp图片,可选。
Text1.Text = jieguo
Picture1.Picture = LoadPicture("c:\code.bmp")
End Sub
2022-06-24 14:58
aroffice
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2011-9-23
得分:0 
回复 2楼 吹水佬
这是网上找的VB代码,需要修改为VFP的代码

程序代码:
Private Declare Function loadcode Lib "ycode.dll" (ByVal code As Long, ByVal Length As Long, ByVal address As String, ByVal pass As String) As Long
Private Declare Function Recognition Lib "ycode.dll" (ByVal ItemNo As Long, ByVal picin As Long, ByVal Length As Long, ByVal Address1 As String, ByVal Address2 As String, lppicout As Long, lpLength As Long, cLength As Long) As Long
Private Declare Function lstrcpy Lib "kernel32" Alias "lstrcpyA" (ByVal lpString1 As String, ByVal lpString2 As Long) As Long
Private Declare Function Writepic Lib "ycode.dll" (ByVal c As String) As Long
Dim strResult As String '识别结果
Dim no1 As Long
Dim no2 As Long
Dim n1 As Long '图片指针
Dim n2 As Long '指针长度

Private Sub Form_Load()
no1 = loadcode(0, 0, "myfc.fc", "") '载入验证码库,把路径换成你的库,当然你也可以直接传递数据,返回项目个数,最后一个参数为库文件密码,如果库文件有密码,这里必须加上
End Sub

Private Sub Command1_Click()

strResult = "    " '验证码都是4个字符的先初始一个4个字节的空白字符串,对于字母长度不定的可以通过Recognition的第8个参数获取字母长度

no1 = Recognition(1, 0, 0, "http://passport., "", n1, n2, 0) '返回识别结果字符的指针,第四个参数为网络地址

no2 = lstrcpy(strResult, no1) '把识别结果放在strResult中

no2 = Writepic("c:\look.bmp")  '把获取的网络图片放在指定的路径,以用来显示,你也可以自己设置自己喜欢的保存路径。

Text1.Text = strResult

Picture1.Picture = LoadPicture("c:\look.bmp") '显示本次识别的图片

End Sub



我从别人做的识别系统内提出ycode.dll, y300xxxx.cll,yxxxx.cll 3个库文件,放到vb程序目录下,正常调用,但每当调用函数的时候就出现错误, 提示内存 ****位置不能为read。识别库没有问题,用我自己的和其他的都一样,是不是我的库文件本身有毛病?

Private Declare Function loadcode Lib "ycode.dll" (ByVal code As Long, ByVal Length As Long, ByVal address As String, ByVal pass As String) As Long
Private Declare Function Recognition Lib "ycode.dll" (ByVal ItemNo As Long, ByVal picin As Long, ByVal Length As Long, ByVal Address1 As String, ByVal Address2 As String, lppicout As Long, lpLength As Long, cLength As Long) As Long
Private Declare Function lstrcpy Lib "kernel32" Alias "lstrcpyA" (ByVal lpString1 As String, ByVal lpString2 As Long) As Long
Private Declare Function Writepic Lib "ycode.dll" (ByVal c As String) As Long
Dim noo As Long
Dim jieguo As String '识别结果
Dim no1 As Long
Dim no2 As Long
Dim n1 As Long '图片指针
Dim n2 As Long '指针长度

Private Sub Command1_Click()
'采用传递网络验证码路径方式
jieguo = " " '验证码都是4个字符的先初始一个4个字节的空白字符串,对于字母长度不定的可以通过Recognition的第8个参数获取字母长度
no1 = Recognition(1, 0, 0, "http://members.china./ci.jpg", "", n1, n2, 0) '返回识别结果字符的指针
no2 = lstrcpy(jieguo, no1) 'VB中用lstrcpy就可以从指针得到字符了,当然你也可以选择其他的方式
no2 = Writepic("") '这行代码的目的是把图片解码成bmp图片,可选。
Text1.Text = jieguo
Picture1.Picture = LoadPicture("c:\code.bmp")

End Sub

Private Sub Command2_Click()
'采用传递本地验证码图片方式
jieguo = " " '验证码都是4个字符的先初始一个4个字节的空白字符串,对于字母长度不定的可以通过Recognition的第8个参数获取字母长度
no1 = Recognition(1, 0, 0, "", "ci.GIF", n1, n2, 0) '返回识别结果字符的指针
no2 = lstrcpy(jieguo, no1) 'VB中用lstrcpy就可以从指针得到字符了,当然你也可以选择其他的方式
no2 = Writepic("") '这行代码的目的是把图片解码成bmp图片,可选。
Text1.Text = jieguo
Picture1.Picture = LoadPicture("c:\code.bmp")
End Sub
2022-06-24 14:59
吹水佬
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:432
帖 子:10064
专家分:41463
注 册:2014-5-20
得分:0 
不能使用提供的文件,测试不了。
2022-06-24 15:05
aroffice
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2011-9-23
得分:0 
链接: https://pan.baidu.com/s/175prV4GKi1MlSw5gcI3fNA?pwd=key9 提取码: key9 复制这段内容后打开百度网盘手机App,操作更方便哦
2022-06-24 15:51
吹水佬
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:432
帖 子:10064
专家分:41463
注 册:2014-5-20
得分:0 
以下是引用吹水佬在2022-6-24 14:00:19的发言:

下载失败,test.rar 被警告有病毒

2022-06-24 19:03



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-509414-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.112649 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved