Failed to create COM object 'X': Class not

2019-01-29 13:23发布

问题:

There already is a working WAMP instance in a Windows 7 in which the line

$x = new COM("X");

does instantiate a COM object.

I was trying to locate a bug, and decided to use a fresh new WAMP installation on the same Windows 7 system as the previous one.

In the new one, the same line produces:

Failed to create COM object 'X': Class not registered ( Error code: 0x80040154 )

Now, since the first WAMP comes with it's own installation application (along with its DLL which holds the COM class) I can't exactly figure out what I need to change in the new WAMP so the line above will instantiate the object.

  • My WAMP version is: 2.2 and
  • Apache version : 2.2.21
  • PHP version : 5.3.10

Any idea what I need to set up properly?

回答1:

You need to register the DLL, using

regsvr32 yourdll.dll


回答2:

Managed to solve the problem by changing the working directory (using chdir) to be the same as the php.exe just before $x = new COM("X");.

I think the DLL wasn't propery registered, or lacked something in itself.