duanduo0520 2018-08-03 13:55
浏览 870
已采纳

PHP错误 - 无法创建COM对象,未注册类

Related questions:

Fatal Error: "Class not registered" creating COM object

Where can I find all of the COM objects that can be created in Powershell?

I'm currently migrating a PHP website from a server running Windows Server 2003 and PHP 5.2 to one running Windows Server 2012 R2 and PHP 5.6.35. One script is giving me a "Class Not Registered" error when creating a COM object:

$obj = new COM('DllName.ClassName') or die ("Unable to create COM object");

I've checked the above questions, and can confirm that:

  • The COM DLL is registered on the server (both by checking the registry and using PowerShell)
  • The installation of PHP is 32-bit (PHP_INT_SIZE is 4).

I think the next thing for me to look at is the "Advanced Settings" dialog mentioned in the answer to the first question above, but where do I find it? The actual server in use is Apache, installed as part of WAMP, but I think the problem is at a lower level.

  • 写回答

2条回答 默认 最新

  • dongwen6743 2018-08-04 06:45
    关注

    The fix was to use the registry hack described in the blog post linked from the first linked question. The full process is:

    1. Copy the ActiveX DLL to C:\Windows\SysWOW64 (not System32).
    2. Open a command prompt, and register the DLL: C:\Windows\SysWOW64>regsvr32 <DllName>
    3. Open the registry (type regedit at the command prompt), and search for the DLL name in HKEY_CLASSES_ROOT\WOW6432Node\CLSID. The DLL should be found in a key named HKEY_CLASSES_ROOT\WOW6432Node\CLSID\{GUID} . Copy the GUID to the clipboard.
    4. Create a new String value named AppID in this key (not in any of its sub-keys). Set the AppID value to the GUID (including braces).
    5. Create a new key: HKEY_CLASSES_ROOT\WOW6432Node\AppID\{GUID} .
    6. In this new key, create a String value named DllSurrogate . Leave the value blank.

    The ActiveX object should now be creatable from PHP using the COM functions.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法