ctypes calling delphi dll
Thomas Heller
theller at python.net
Wed Dec 18 10:51:48 EST 2002
Brian Elmegaard <brian at rk-speed.rugby.dk> writes:
> Brian Elmegaard <brian at rk-speed.rugby.dk> writes:
>
> > Thomas Heller <theller at python.net> writes:
> >
> > > and it seems to work. It prints 'R11'. Is this what you expected?
> >
> > Yep. Thanks a lot for the help.
>
> And now I got it all working, but have written the code below in the
> best possible way? I don't think it is much easier to read than the
> C-code example, I am copying.
If you are using ctypes, you're basically 'programming in C'.
It is up to you to organize this code in a more pythonic way.
What I found useful is to write wrapper functions (or a class)
in a separate module. Something like this (untested) for the PDewT
function, and use it from your client code:
---- refrig.py
import ctypes
RefrigC = ctypes.cdll.RefrigC
_PDewT = RefrigC.PDewT
_PDewT.restype = 'f'
def PDewT(f):
return _PDewT(c_double(f))
-----
Thomas
More information about the Python-list
mailing list