【发布时间】:2011-12-15 16:19:16
【问题描述】:
这里的基本细节如下:
- Windows Server 2008 64 位
- Python26 64位
- 安装 Crystal Reports(32 位和 64 位运行时)的 Visual Studio 2008(团队)
我的问题是以下代码在调用 Dispatch('CrystalRuntime.Application') 时失败,这在上述相同的 32 位操作系统配置上运行良好。
错误是:
(-2147221164, 'Class not registered', None, None)
我已经花了几个小时研究失败的各种原因,但我一无所获..
我什至在 'Crystal Reports ActiveX Designer 运行时库'上运行了 makepy.py,其中包含我正在尝试创建的 com 接口,但即使这样也无法提供结果。
我知道 Crystal 安装正确,因为它运行良好,并且我可以看到正确注册的 com 类。
我完全卡住了,需要帮助,一如既往,我希望 stack 能再次拯救我...
任何想法,请记住,我不是任何级别的 Python 程序员......
import os
import sys
import re
import time
from win32com.client import Dispatch
import pythoncom
def main():
try:
app = Dispatch('CrystalRuntime.Application')
print app
except pythoncom.com_error, e:
print "(crystal reports not installed?): '%s'" % e
return 0
print 'Success!!!'
if __name__ == '__main__':
main()
【问题讨论】:
-
好的,进一步分析一下。如果我在 vb 脚本文件中或多或少地做同样的事情,并使用“cscript.exe”调用脚本文件,最初我会得到相同的结果。但是,如果我使用 'C:\Windows\SysWOW64\cscript.exe' 调用 vb 脚本文件,我相信它会将此脚本作为 32 位进程运行,它可以工作。所以.....我需要做什么才能让python脚本表现相同,因为我不想在vb中重写整个脚本,只是为了几行不起作用。跨度>
标签: python crystal-reports 64-bit