[python-win32] finding pythonXX.dll?

Thomas Heller theller at ctypes.org
Tue May 4 19:40:20 CEST 2010


Bill Janssen schrieb:
> Roger Upole <rwupole at msn.com> wrote:
> 
>> Bill Janssen wrote:
>> > Is there anyway to tell, from inside Python, where the python26.dll file
>> > is?  I've got to install the win32 dlls in the same directory.
>> >
>> > I see that sys contains a symbol "dllhandle", but that's just a
>> > numeric handle.
>> >
>> > Bill
>> 
>> win32api.GetModuleFileName(sys.dllhandle)
>> 
>>      Roger
> 
> Sorry, I wasn't clear enough.  I'm trying to figure out where to install
> the win32 dlls, so I can't use them in that determination.

Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import *
>>> buf = create_string_buffer(256)
>>> windll.kernel32.GetModuleFileNameA
<_FuncPtr object at 0x00B44B70>
>>> import sys
>>> windll.kernel32.GetModuleFileNameA(sys.dllhandle, byref(buf), 256)
32
>>> buf.value
'C:\\WINDOWS\\system32\\python26.dll'
>>>

-- 
Thomas



More information about the python-win32 mailing list