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

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 springmvc重定向和返回json
  • ¥15 数学建模——参会安排怎么做
  • ¥15 电脑键盘实现触摸功能
  • ¥25 matlab无法将表达式转换为双数组怎么解决?
  • ¥15 单片机汇编语言相关程序
  • ¥20 家用射频美容仪技术规格
  • ¥15 大家帮我看看为什么错了
  • ¥15 unity互动琴弦抖动效果
  • ¥15 做了个的二极管反向饱和电流测量电路,但是测试达不到效果
  • ¥15 nginx无证书访问https失败