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条)

报告相同问题?

悬赏问题

  • ¥15 在若依框架下实现人脸识别
  • ¥15 网络科学导论,网络控制
  • ¥100 安卓tv程序连接SQLSERVER2008问题
  • ¥15 利用Sentinel-2和Landsat8做一个水库的长时序NDVI的对比,为什么Snetinel-2计算的结果最小值特别小,而Lansat8就很平均
  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同