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