2

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 Answers 2

5

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.

Sign up to request clarification or add additional context in comments.

4 Comments

Congratulations. If problems occurred in the standard procedure, how about raising issues to the relevant projects?
This worked for me registering a completely different DLL by hand, thank you
@Tevildo, i am trying to add tsclibnet.dll file in PHP but not working can you help me ?below one is example and DLL to be load in system.fs.tscprinters.com/en/dl/1/3378
@AmitJoshi Yours is a .NET dll, not COM/ActiveX. This question may be helpful.
0

This may be due to a function change called session 0 isolation.

As a result, it was up to Windows Server 2003 that COM could be used in service. It can not be used from Windows Server 2008. And on Windows Vista which is the workstation side, COM can not be used from programs started as a service as well.

Impact of Session 0 Isolation on Services and Drivers in Windows

In Windows XP, Windows Server 2003, and earlier versions of Windows, all services run in Session 0 along with applications. This situation poses a security risk. In Windows Vista, Windows Server 2008, and later versions of Windows, the operating system isolates services in Session 0 and runs applications in other sessions, so services are protected from attacks that originate in application code.

Please do not use COM on the server side as shown in the following office article.

Considerations for server-side Automation of Office

2 Comments

That seems fairly catastrophic, but (as far as I know) PHP doesn't run as a service, and this would break all of PHP's COM functions - there isn't anything about it in the PHP manual . I'm fairly sure it's not so fundamental a problem.
In that case, Apache is running as a service? There was such an article.apache service php exec not working Besides, does the 32/64 bit configuration of Apache/PHP and COM Object not match?.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.