Call C functions from Python

Grant Edwards grante at visi.com
Tue Oct 4 17:07:58 EDT 2005


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