Python                                                          Home :





Python - Loading DLL


There are several ways of loading a dll and calling a function implemented in the dll. Also even with a same method/function, there are many details to be considered depending on the characteristics of dll and function in it.

The only way to get familiar with all those trick is to go through many examples. (You can refer to 15.17. ctypes A foreign function library for Python but it would be difficult to understand the real meaning of those description unless you try on your own)


Example 1 >



    import ctypes


    MB_ICONEXCLAMATION = ctypes.c_uint(int("0x30",0));

    NULL = None;


    hDllUser32 = ctypes.WinDLL('user32.dll')

    ret = hDllUser32.MessageBoxA(NULL,

                                 b'This is a MessageBox wrapping MessageBoxA()',

                                 b'Message Box Test',



    del hDllUser32;