[python-win32] ctypes and DLL

Thomas Heller theller at ctypes.org
Thu Jul 24 12:12:43 CEST 2008


Marcus.CM schrieb:
> Hi
> 
> On Windows/Vista :-
> 
>   vr = ctypes.CDLL(str)   
> 
> When loading a DLL that is corrupted using cytpes,  i get a bombed out 
> box with "python.exe - bad image" as the message box title instead of 
> handling it at my exception handler.
> How do i do this without the ugly messagebox from python ?
> 
> Marcus.CM.

You could try changing the process error-mode flags by calling the
Windows SetErrorMode() function before loading the dll.

Probably ctypes.windll.kernel32.SetErrorMode(0x8007) will help.
See http://msdn.microsoft.com/en-us/library/ms680621(VS.85).aspx
-- 
Thomas



More information about the python-win32 mailing list