在 64 位 Windows 7 机器上使用 Python 构建 Com 服务器
原帖在这里: http://mail.python.org/pipermail/python-win32 /2010-12月/011011.html
我正在使用:
- 操作系统:64 位 Windows 7 Professional
- Python:python-2.7.1.amd64
- Python win32 扩展:pywin32-214.win-amd64-py2.7
- Py2exe:py2exe-0.6.9.win64-py2.7.amd64
我正在尝试为 Windows 构建图标覆盖。它在 32 位上运行良好 Windows,但不能在 64 位 Windows 7 上工作。
以下是我为测试创建的 Python 模块:
test_icon_overlay.py: ( http://mail.python.org/pipermail/python-win32/attachments/20101229/bb8c78a4/attachment-0002.obj )用 Python 创建的 com 服务器用于图标覆盖 在“C:\icons”文件夹上添加复选标记覆盖图标(C:\icons\test.ico)
setup_VI.py: ( http://mail.python.org/pipermail/python-win32/attachments/20101229/bb8c78a4/attachment-0003.obj ) 创建 test_icon_overlay.dll 的安装文件
- icon.zip: ( http://mail.zip.zip python.org/pipermail/python-win32/attachments/20101229/bb8c78a4/attachment-0001.zip )为了测试,您应该在 C:\ 中提取 icon.zip
图标覆盖出现在 C:\icons<当我执行
python 时 /code> 文件夹 Windows 命令提示符下的 test_icon_overlay.py
并重新启动 explorer.exe
。 但它不适用于使用 setup_VI.py 创建的 dll 文件
我已经使用 python setup_VI.py py2exe 创建了 dll 文件,然后尝试 使用 regsvr32 test_icon_overlay.dll 注册它。注册失败并显示 Windows 错误消息注册 shell 扩展时出现错误 0x80040201
。
然后我在 Python27/Lib/site-packages/py2exe/boot_com_servers.py
中打开了记录器,这是我在 comerror.txt
中得到的回溯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
看起来 win32api.GetModuleFileName(sys.frozendllhandle)
或 64 位 Windows 7 上的 dll 构建可能存在问题。
此外,我还看到了 < code>pywin32-214.win-amd64-py2.7 在 64 位 Windows 7 上完成时显示错误消息: 快照
close failed in file object destructor:
sys.excepthook is missing
lost sys.stderr
我做错了什么吗?对此的任何帮助都是高度的 赞赏。
Original post is here:
http://mail.python.org/pipermail/python-win32/2010-December/011011.htmlI 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:
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" foldersetup_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.- 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
on Windows command prompt and restarts
test_icon_overlay.pyexplorer.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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
64 位 Python 上的 py2exe 存在错误。由 py2exe 初始化的 sys.frozendllhandle 无效,因此 win32api.GetModuleFileName(sys.frozendllhandle) 失败。
您可能想尝试 http://www.lfd.uci 处的修补后的 py2exe 安装程序.edu/~gohlke/pythonlibs/#py2exe
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