Accessing a dll from Python

Richie Hindle richie at entrian.com
Thu Oct 20 15:31:44 CEST 2005


[Daniel]
> I tried the ctypes module.

ctypes is the right way to do it.  You need to post your code and whatever
errors you received.  Here's an example of using ctypes to call a DLL:

>>> from ctypes import *
>>> windll.user32.MessageBoxA(None, "Hello world", "ctypes", 0);

You use "windll" for stdcall functions (eg. the Windows API) and "cdll" for
cdecl functions.  I don't know which one VB defaults to.  If you get it
wrong, ctypes will give you an error talking about using the "wrong calling
convention".

-- 
Richie Hindle
richie at entrian.com



More information about the Python-list mailing list