简体   繁体   English

使用PHP从服务(Apache)访问COM接口

[英]Access a COM interface from a service (apache) with PHP

I've been trying to create a PHP script which will run on a locally hosted web server, and will be able to access various programs on my computer through COM. 我一直在尝试创建一个PHP脚本,该脚本将在本地托管的Web服务器上运行,并且能够通过COM访问计算机上的各种程序。 I've had mixed success and failure, and I've been able to narrow down the problem. 我经历过成功和失败,而且能够缩小问题的范围。

If I run the php script using php.exe, it works. 如果我使用php.exe运行php脚本,则可以运行。
If I run the php script using apache running from the command-line, it works. 如果我使用从命令行运行的apache运行php脚本,则它可以工作。
If I run the php script using apache running as a service, it fails. 如果我使用作为服务运行的apache运行php脚本,它将失败。

I'm running Windows 7 Pro x64, apache 2.2, PHP 5.3, and the particular program I'm trying to access is MediaMonkey, my music player. 我正在运行Windows 7 Pro x64,Apache 2.2,PHP 5.3,并且我尝试访问的特定程序是我的音乐播放器MediaMonkey。

Any ideas? 有任何想法吗? If I have to I can just run the server without it being a service, but I would like to figure this out. 如果必须的话,我可以只运行服务器而不将其作为服务,但是我想弄清楚这一点。

Don't have a Windows 7 box to hand, (I'm actually looking at an XP box) but it's likely to be something similar: 没有手拿Windows 7的盒子,(我实际上是在看XP盒子),但是可能是类似的东西:

  • Pull up the Admin Tools / Services 拉起管理工具/服务
  • Right click on your Apache Web Server service and select properties. 右键单击您的Apache Web服务器服务,然后选择属性。
  • There should be an option here (possibly on the Log On tab) to log on as local system account and "Allow service to interact with desktop"... ensure that it's checked. 这里应该有一个选项(可能在“登录”选项卡上)以本地系统帐户的身份登录,并且“允许服务与桌面交互” ...确保已选中。
  • Save the setting and Restart Apache 保存设置并重新启动Apache

Don't know for certain that this is the solution to your problem, but it fixed something similar for me a year or so ago 不确定是否可以解决您的问题,但是大约一年前,它为我解决了类似问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM