Running in Release or Debug version of the python interpreter?

Fredrik Lundh fredrik at pythonware.com
Tue May 24 11:01:35 EDT 2005


Raphael Zulliger wrote:

long version: I'm using ctypes to load my own dll. There exists 2
> version of this dll - a debug and a release version (where one is linked
> against debug C runtime dll and the other to release C runtime dll). Now
> I have to change the name of the dll I want to be loaded by ctypes...
> But how can I find out which of the dll I have to load?!

calling GetModuleFileName (in kernel32.dll) on sys.dllhandle should give
you the name of the current Python DLL.  something like this should work:

    from ctypes import *
    MAX_PATH = 500
    filename = c_buffer(MAX_PATH)
    windll.kernel32.GetModuleFileNameA(sys.dllhandle, filename, MAX_PATH)
    filename = filename.value

</F> 






More information about the Python-list mailing list