CTypes

Chris Mellon arkanes at gmail.com
Mon Feb 5 10:36:02 EST 2007


On 2/4/07, Dennis Lee Bieber <wlfraed at ix.netcom.com> wrote:
> On 4 Feb 2007 05:16:27 -0800, "SoutoJohn at gmail.com"
> <SoutoJohn at gmail.com> declaimed the following in comp.lang.python:
>
>
> > script file 'test.py' and a DLL 'AutoIt3X.DLL' in the same folder, how
> > could I load it? The tutorial did something like dll=windll.kernel32,
> > which I understands loads the kernel but I don't see how I could apply
> > that to load AutoIt3X. Thanks in advanced.
>
>         I've not used ctypes, but from all the examples I've seen....
>
>         What happens if you specify:
>
>         dll = ctypes.windll.AutoIt3X
>
>         I think ctypes uses a getattr() trap to extract the dll name from
> the invocation, then passes that to the Windows library loading code.
> --

This is indeed what ctypes does. There's also a LoadLibrary static
method of windll.cdll etc that you can use to get it explicitly (like
if you need to load a DLL not on your path).

dll = ctypes.windll.LoadLibrary(r"C:\AutoIT#x.dll")



More information about the Python-list mailing list