- 论坛徽章:
- 0
|
本帖最后由 mujian669 于 2012-05-23 19:50 编辑
一个图片识别的dll,原版给了vb的文档和例子,我想用python实现,结果怎么也没成功,希望大家给看看应该怎么办。
vb里面的文档和代码:
Private Declare Function GetByteVcode Lib "Vcode.dll" (ByVal ByteData As String, ByVal ByteLength As String, ByVal Index As String, ByVal Result As String) As Boolean- Private Sub Command4_Click()
- Dim Gt As Boolean, Result As String
-
- Dim a() As Byte
- Dim n As Long
- Dim b As Long
- a = Xhttp("http://......")
- n = VarPtr(a(0))
- b = UBound(a) + 1
-
- Rem
- Result = Space$(100)
-
- Gt = GetByteVcode(n, b, 1, Result)
-
- Text2.Text = Result
- End Sub
复制代码 自己绞尽脑汁,多方求助,写了下面的代码:- # -*- coding: utf-8 -*-
- import ctypes,cookielib, urllib,urllib2,os
- cj = cookielib.LWPCookieJar()
- opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
- opener.addheaders = [('Accept-Language','zh-cn'),('Content-Type','...')]
- urllib2.install_opener(opener)
- sock = opener.open("http://……","rb")
- fp = sock.read()
- sock.close()
- pStr = ctypes.POINTER(ctypes.c_char)()
- pStr.value = fp
- pVoid = ctypes.cast( pStr, ctypes.POINTER(ctypes.c_int))
- ml=os.getcwd()
- dll=ctypes.windll.LoadLibrary(ml+'\\Vcode.dll')
- var=" "
- dll.GetByteVcode(pVoid,len(pStr.value),"1",var)
- print var
复制代码 结果还是报错:WindowsError: exception: access violation reading 0x000005B8
请问大家这个错在哪里了啊? |
|