llamando una dll con ctypes
Publicado por Dario (1 intervención) el 06/05/2006 01:31:43
Using ctypes I can call the windows dll file without problems now but later I need to call functions from this dll file with diferents arguments, for example idem call from C code is:
int x400_channel;
int status;
struct X400mtSession *sp;
status = X400mtOpenVer (x400_channel, &sp);
My py code and error :
>>> from ctypes import *
>>> libc = windll.LoadLibrary("libx400mt.dll")
>>> status = c_int()
>>> sp = c_int()
>>> x400_channel = c_int()
>>>
>>> status = libc.X400mtOpenVer(x400_channel, sp)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
WindowsError: exception: access violation writing 0x00000000
Now I have tryed too:
>>> status = libc.X400mtOpenVer(x400_channel, byref(sp))
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ValueError: Procedure probably called with too many arguments (8 bytes in excess
Using ctypes I can call the windows dll file without problems now but later I need to call functions from this dll file with diferents parameters, for example idem call from C code is:
int x400_channel;
int status;
struct X400mtSession *sp;
status = X400mtOpenVer (x400_channel, &sp);
Python Fan
Joined: 03 May 2006
Posts: 5
Reply with quote Edit/Delete this post
Post
by other side, my Visual FoxPro code work fine:
DECLARE INTEGER X400mtOpenVer IN LIBX400MT.DLL ;
INTEGER nversion ,;
INTEGER @X400mtSession
credentials=0
X400mtSession=0
status = X400mtOpenVer( credentials,@X400mtSession)
?status
status=0 && 0=session open
int x400_channel;
int status;
struct X400mtSession *sp;
status = X400mtOpenVer (x400_channel, &sp);
My py code and error :
>>> from ctypes import *
>>> libc = windll.LoadLibrary("libx400mt.dll")
>>> status = c_int()
>>> sp = c_int()
>>> x400_channel = c_int()
>>>
>>> status = libc.X400mtOpenVer(x400_channel, sp)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
WindowsError: exception: access violation writing 0x00000000
Now I have tryed too:
>>> status = libc.X400mtOpenVer(x400_channel, byref(sp))
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ValueError: Procedure probably called with too many arguments (8 bytes in excess
Using ctypes I can call the windows dll file without problems now but later I need to call functions from this dll file with diferents parameters, for example idem call from C code is:
int x400_channel;
int status;
struct X400mtSession *sp;
status = X400mtOpenVer (x400_channel, &sp);
Python Fan
Joined: 03 May 2006
Posts: 5
Reply with quote Edit/Delete this post
Post
by other side, my Visual FoxPro code work fine:
DECLARE INTEGER X400mtOpenVer IN LIBX400MT.DLL ;
INTEGER nversion ,;
INTEGER @X400mtSession
credentials=0
X400mtSession=0
status = X400mtOpenVer( credentials,@X400mtSession)
?status
status=0 && 0=session open
Valora esta pregunta


0