tags:

views:

153

answers:

1

I'm trying to call a function Size() from a custom COM DLL from PHP. That function should return a struct with 4 members (top, left, bottom, right) however when I call that function from PHP I get the following error:

Error [0x80070057] The parameter is incorrect.

I don't pass it any parameter and according to the specs it should not get any parameter but return a struct.

I'm able to succesfully call other COM functions from that same COM DLL.

If I call com_print_typeinfo() from PHP I can see that PHP thinks the function is defined as follows:

function Size( ) { } /* DISPID=3 */

If I open the tlb file in VS 2005 it shows it as

Function Size() As TBoxRect

And it shows that TBoxRect is a structure with 4 members just like it should be.

So PHP seems to think that the function returns nothing which is not correct. How can I make this function that should return a struct work from PHP using COM?

+1  A: 

PHP can only express OLE automation compatible types; "COM" is a misnomer (my bad), it is really an "OLE Automation" extension.

Your TBoxRect is a C structure type that has no IDispatch or Variant representation, so PHP cannot map that type.

If you make a wrapper type that implements IDispatch to use in place of TBoxRect, you will have more luck.

If you are not the author of that COM DLL, then you can implement that proxy wrapper in another language that can access TBoxRect and return it in a form that PHP can access (either create a wrapper object, or a wrapper array for each of the values). You would then have PHP create an instance of the wrapper object and you should be set.

Wez Furlong
The author of the COM DLL has made a wrapper that implements IDispatch and now it's working correctly from PHP. Thank you for the answer.
Robbie