调用 CoInitialize() 的语法;来自 PHP?

发布于 2024-12-13 04:44:40 字数 457 浏览 3 评论 0原文

我正在尝试组装一个服务器,将 HTML 转换为本机 Word 文档。它可以工作,但有时我会收到以下错误:

Uncaught exception 'com_exception' with message 'Failed to create COM object `word.application': CoInitialize has not been called.

我使用的是 PHP,而不是 ASP 或更多 Microsoft-y 的东西,因为它应该只是一个快速项目。

我像这样初始化一个 COM 对象:

$word = new COM("word.application") or die("Unable to instantiate Word");

谁能告诉我如何从 PHP 调用 CoInitialize() ?

非常感谢

I'm trying to hack together a server that turns HTML into native Word docs. It works, but some of the time I get the following error:

Uncaught exception 'com_exception' with message 'Failed to create COM object `word.application': CoInitialize has not been called.

I'm using PHP and not ASP or something more Microsoft-y because it is supposed to just be a quick project.

I initialize a COM object like this:

$word = new COM("word.application") or die("Unable to instantiate Word");

Could anyone tell me how I can call CoInitialize() from PHP?

Many thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冷情 2024-12-20 04:44:40

检查并确保您没有任何 WINWORD.EXE 的恶意副本。我遇到了这个错误,当我检查时,我有 36 个 WINWORD.EXE 副本正在运行。我显然错过了与 COM 对象断开连接的一些逻辑,因此每次重新加载脚本时,现有的 WINWORD 都会陷入困境,而新的 WINWORD 会启动。一旦我删除了所有的 WINWORD,错误就消失了。

Check to make sure you don't have any rogue copies of WINWORD.EXE hanging around. I ran into this error, and when I checked, I had 36 copies of WINWORD.EXE running. I had apparently missed some logic in disconnecting from the COM object, so every time I reloaded the script, the existing WINWORD was left in limbo while a new one launched. Once I nuked all the WINWORDs, the error went away.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文