在 64 位 Windows 7 机器上使用 Python 构建 Com 服务器 [英] Com server build using Python on 64-bit Windows 7 machine

查看:50
本文介绍了在 64 位 Windows 7 机器上使用 Python 构建 Com 服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

原帖在这里:http://mail.python.org/pipermail/python-win32/2010-12 月/011011.html

我正在使用:

  • 操作系统:64 位 Windows 7 专业版
  • 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.

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.

以下是我为测试而创建的 Python 模块:

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 ) 用 Python 创建的用于图标覆盖的 com 服务器在C:icons"文件夹中添加复选标记覆盖图标(C:icons est.ico)

  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 est.ico) on "C:icons" folder

setup_VI.py: ( http://mail.python.org/pipermail/python-win32/attachments/20101229/bb8c78a4/attachment-0003.obj ) 安装文件,它为分布.

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.

当我执行 python 时,图标覆盖出现在 C:icons 文件夹中test_icon_overlay.py 在 Windows 命令提示符下并重新启动 explorer.exe.但它不适用于使用 setup_VI.py

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

我使用 python setup_VI.py py2exe 创建了 dll 文件,然后尝试使用 regsvr32 test_icon_overlay.dll 注册它.注册失败windows 错误消息 Error 0x80040201 while registering shell extension.

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.

然后我在 Python27/Lib/site-packages/py2exe/boot_com_servers.py 中打开记录器,这是我在 comerror.txt 上得到的回溯<代码>regsvr32test_icon_overlay.dll

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

看起来 win32api.GetModuleFileName(sys.frozendllhandle) 或 64 位 Windows 7 上的 dll 构建可能存在问题.

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

此外,我看到在 64 位 Windows 7 上安装 pywin32-214.win-amd64-py2.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.

推荐答案

在 64 位 Python 上的 py2exe 中存在一个错误.由 py2exe 初始化的 sys.frozendllhandle 无效,导致 win32api.GetModuleFileName(sys.frozendllhandle) 失败.

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.

您可能想在 http://www 上尝试修补 py2exe 安装程序.lfd.uci.edu/~gohlke/pythonlibs/#py2exe

这篇关于在 64 位 Windows 7 机器上使用 Python 构建 Com 服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆