modifying DLL string table programatically (Was: Win32 Binary-only for 2.3.x?)

Thomas Heller theller at python.net
Mon Jan 9 13:53:12 EST 2006


Trent Mick <trentm at ActiveState.com> writes:

> [Thomas Heller wrote]
>> py2exe also does something like this in the copy of pythonXY.dll that it
>> creates, to avoid the resulting exe pulling in sys.path entries from the
>> registry.
>
> Do you have a quick pointer to the code that does this? I wasn't easily
> able to automate doing this with COM code last time I tried.

Python\lib\site-packages\py2exe\build_exe.py, function
patch_python_dll_winver().

The py2exe_util extension has exports add_resource, which wraps
BeginUpdateResource, UpdateResource, and EndUpdateResource, but they are
also wrapped in pywin32 somewhere.  Stringtables are a little bit more
difficult that other resources, but see
py2exe\resources\StringTables.py.

The most important thing to remember is that these functions may
silently fail if the image file to modify is readonly.  Or something
like that.

Thomas





More information about the Python-list mailing list