在64位Windows 7计算机上使用Python构建Com服务器

Vij*_*pte 3 python 64-bit pywin32 py2exe

原帖如下:http: //mail.python.org/pipermail/python-win32/2010-December/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上运行不正常.

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

  1. test_icon_overlay.py:(http://mail.python.org/pipermail/python-win32/attachments/20101229/bb8c78a4/attachment-0002.obj的Python为图标叠加创建)COM服务器这增加了复选标记图标覆盖(C:\icons\test.ico)在"C:\ icons"文件夹中

  2. setup_VI.py:(http://mail.python.org/pipermail/python-win32/attachments/20101229/bb8c78a4/attachment-0003.obj其分配创建test_icon_overlay.dll)安装文件.

  3. icons.zip :( http://mail.python.org/pipermail/python-win32/attachments/20101229/bb8c78a4/attachment-0001.zip)进行测试你应该在C:中提取icons.zip

C:\icons当我python test_icon_overlay.py在Windows命令提示符下执行并重新启动时,文件夹上会出现图标覆盖explorer.exe.但它不能使用创建的dll文件setup_VI.py

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

然后我打开记录器Python27/Lib/site-packages/py2exe/boot_com_servers.py,在这里是我得到的回溯comerror.txtregsvr32 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
Run Code Online (Sandbox Code Playgroud)

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

此外,我看到pywin32-214.win-amd64-py2.7在64位Windows 7上的安装完成时出现错误消息:快照

close failed in file object destructor:
sys.excepthook is missing
lost sys.stderr
Run Code Online (Sandbox Code Playgroud)

有什么我做错了吗?对此的任何帮助都非常感谢.

cgo*_*lke 5

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

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

  • 我将补丁提交到https://sourceforge.net/tracker/index.php?func=detail&aid=3152707&group_id=15583&atid=115583 (2认同)