I guess it because the type of str(Ansi or Unicode),but I have no idea about the usage of it.Could you help me,thx very much.
Code: Select all
dllpath:=A_SCRIPTDIR "\WmCode.dll"
Msgbox DllCall("LoadLibrary","Str",dllpath)
filePath:=A_SCRIPTDIR "\网易论坛.dat"
MsgBox DllCall(dllpath "\LoadWmFromFile","AStr",filePath,"AStr","163","Int") ;password="163"
ImgFile:=A_SCRIPTDIR "\temp.jpg"
VarSetCapacity(code, 255)
MsgBox DllCall(dllpath "\GetImageFromFile","Str",ImgFile,"Uint",&code,"Int")
MsgBox code
vb 6.0 for example
Code: Select all
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
'请根据自己的情况修改WmCode.dll所在路径
Private Declare Function LoadWmFromBuffer Lib "WmCode.dll" (ByVal FileBuffer As Long, ByVal FileBufLen As Long, ByVal Password As String) As Boolean
Private Declare Function LoadWmFromFile Lib "WmCode.dll" (ByVal FilePath As String, ByVal Password As String) As Boolean
Private Declare Function GetImageFromFile Lib "WmCode.dll" (ByVal FilePath As String, ByVal Vcode As String) As Boolean
Private Declare Function GetImageFromBuffer Lib "WmCode.dll" (ByVal ImgBuffer As Long, ByVal ImgBufLen As Long, ByVal Vcode As String) As Boolean
Private Declare Function SetWmOption Lib "WmCode.dll" (ByVal OptionIndex As Long, ByVal OptionValue As Long) As Boolean
Private Sub Command1_Click()
Dim Image() As Byte
Dim ImgFile As String
Dim ImgURL As String
ImgFile = "temp.jpg"
ImgURL = txtURL.Text
Call URLDownloadToFile(0, ImgURL, ImgFile, 0, 0)
Picture1.Picture = LoadPicture(ImgFile)
End Sub
Public Function MyReadFile(FilePath As String, FileBuffer() As Byte)
Dim FileSize As Long '文件长度
FileSize = FileLen(FilePath) '获取文件长度
ReDim FileBuffer(FileSize - 1) As Byte
Open FilePath For Binary As #1
Get #1, , FileBuffer
Close
End Function
Private Sub Command2_Click()
Dim Image() As Byte
Dim ImgFile As String
Dim Vcode As String
Vcode = " " '必须先对这个变量赋多个空格,空格数量要比验证码字符数量多1
ImgFile = "temp.jpg"
Call MyReadFile(ImgFile, Image)
'文件接口调用验证码图像并识别
'If (LoadWmFromFile(ImgFile, Vcode)) Then
'Text1.Text = Vcode
'End If
'----------------------------
'内存接口调用验证码图像并识别
If (GetImageFromBuffer(VarPtr(Image(0)), UBound(Image), Vcode)) Then
Text1.Text = Vcode
End If
End Sub
Private Sub Command3_Click()
'请根据自己的情况修改dat所在路径,字库密码为 163
If (LoadWmFromFile(txtPath.Text, "163") = False) Then
MsgBox "载入识别库出错。"
End If
If (SetWmOption(6, 90) = False) Then
MsgBox "设置最小相似度出错。"
End If
Command1.Enabled = True
Command2.Enabled = True
End Sub
Code: Select all
#coding=gbk
#第一行注释不能省,指定编码声明以支持中文
#本代码文件在32位的python 3.4.3版测试通过
import urllib
import time
import string
import ctypes
from ctypes import *
dll = ctypes.windll.LoadLibrary('WmCode.dll')
#如果dll不在当前目录,那么需要指定全路径
other language for example and the dll have been uploaded to the site.
http://u.163.com/7xEdrb6L
f8dWoeWw
googledrive
https://drive.google.com/open?id=1uo9RV ... FMJbkS0iK4