3

Original post is here: http://mail.python.org/pipermail/python-win32/2010-December/011011.html

I am using:

  • OS: 64 bit Windows 7 Professional
  • Python: python-2.7.1.amd64
  • Python win32 extensions: pywin32-214.win-amd64-py2.7
  • Py2exe: py2exe-0.6.9.win64-py2.7.amd64

I am trying to build icon overlay for Windows. It has worked fine on 32 bit Windows but not working on 64 bit Windows 7.

Here are the Python modules I have created for testing:

  1. test_icon_overlay.py: ( http://mail.python.org/pipermail/python-win32/attachments/20101229/bb8c78a4/attachment-0002.obj ) com server created in Python for icon overlay which adds check mark overlay icon(C:\icons\test.ico) on "C:\icons" folder

  2. setup_VI.py: ( http://mail.python.org/pipermail/python-win32/attachments/20101229/bb8c78a4/attachment-0003.obj ) setup file which creates test_icon_overlay.dll for distribution.

  3. icons.zip: ( http://mail.python.org/pipermail/python-win32/attachments/20101229/bb8c78a4/attachment-0001.zip ) for testing you should extract icons.zip inside C:\

Icon overlay appears on C:\icons folder when I execute python test_icon_overlay.py on Windows command prompt and restarts explorer.exe. But its not working with the dll file created using setup_VI.py

I have created dll file using python setup_VI.py py2exe and then tried to register it using regsvr32 test_icon_overlay.dll. Registration fails with windows error message Error 0x80040201 while registering shell extension.

Then I turned on logger in Python27/Lib/site-packages/py2exe/boot_com_servers.py and here is the traceback which I am getting in comerror.txt on regsvr32 test_icon_overlay.dll

PATH is ['C:\\root\\avalon\\module\\sync\\python\\src\\dist\\library.zip']
Traceback (most recent call last):
  File "boot_com_servers.py", line 37, in <module>
pywintypes.error: (126, 'GetModuleFileName', 'The specified module could not
be found.')
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'DllRegisterServer' is not defined

Looks like there might be a problem with win32api.GetModuleFileName(sys.frozendllhandle) or with the dll build on 64-bit Windows 7.

Also, I saw that installation of pywin32-214.win-amd64-py2.7 on 64-bit Windows 7 finish with the error message: Snapshot

close failed in file object destructor:
sys.excepthook is missing
lost sys.stderr

Is there anything which I am doing wrong? Any help on this is highly appreciated.

6
  • 1
    When you say it works on 32-bit Windows, is that the 32-bit Windows 7 or an older version like Windows XP? If you haven't tried a 32-bit version of the same OS where 64-bit doesn't work then the problem may not be the 64-bitness at all. For example, if it works in XP but not Win7 then it could be UAC related. Commented Jan 3, 2011 at 8:48
  • I have tested dll generated on 32-bit Windows XP on 32-bit Windows XP, Vista and Win7 and icon overlay works fine on each OS. But 64-bit dll generated on 64-bit Windows XP/Win7 did not worked at all on 64-bit XP/Win7 machine. Registration of dll failed on 64-bit machine. Commented Jan 3, 2011 at 12:33
  • Probably a stupid question, but when executing regsvr32 the cmd window is being run with admin privileges, right? Commented Jan 3, 2011 at 14:45
  • I have tried on Win7 using Administrator account and command prompt was invoked with Admin privileges. Commented Jan 4, 2011 at 4:53
  • There is a slightly simpler setup here with same problem: stackoverflow.com/questions/4619701/… Commented Jan 6, 2011 at 22:17

1 Answer 1

5

There's a bug in py2exe on 64 bit Python. The sys.frozendllhandle, initialized by py2exe, is invalid such that win32api.GetModuleFileName(sys.frozendllhandle) fails.

You might want to try the patched py2exe installers at http://www.lfd.uci.edu/~gohlke/pythonlibs/#py2exe

Sign up to request clarification or add additional context in comments.

2 Comments

Where can I see the actual patch to py2exe?
I submitted the patch to sourceforge.net/tracker/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.