Call C functions from Python
Java and Swing
codecraig at gmail.com
Wed Oct 5 08:09:21 EDT 2005
I used, myApp = CDLL("C:...") ...as I saw it in one of the ctypes
samples.
Anyhow, I tried...
myApp = cdll.LoadLibrary("C:\\myapp.dll")
myApp.AddNumbers(1, 4)
..I get an error...
AttributeError: function 'AddNumbers' not found
...myapp certainly has AddNumbers.
Grant Edwards wrote:
> On 2005-10-04, Java and Swing <codecraig at gmail.com> wrote:
> > ok i got ctypes...now i try
> >
> >>> from ctypes import *
> >>> myApp = CDLL("C:\\myapp.dll")
>
> I've never seen that sort of usage before. I don't know what
> CDLL does, and I can't find it in the docs anywhere.
>
> Based on my reading of the tutorial, I would have tried eitehr
>
> myApp = cdll.myapp
> or
> myApp = cdll.LoadLibrary("C:/myapp.dll")
>
> > ..now how can I call functions on in myapp.dll? From the
> > tutorial I am not sure..
>
> Assuming CDLL did something equivalent to cdll.LoadLibrary(),
> I'd try:
>
> myApp.FuncName()
>
> I've always done it the way it's done in the tutorial:
>
> mylib = windll.Lib_Name
> mylib.myFuncName()
>
> > i try, dir(cdll.myApp) and dir(myApp)..but don't see my
> > functions listed.
>
> I don't think dir() works on dll's like that. I certainly
> don't see it mentioned in the tutorial. What happened when you
> tried calling the function the way the tutorial does?
>
> myapp = cdll.myapp
> myapp.MyFunc()
>
> --
> Grant Edwards grante Yow! Yow! Is my fallout
> at shelter termite proof?
> visi.com
More information about the Python-list
mailing list