Page 1 of 1

Problem passing SAFEARRAY to COM object

Posted: Sat Nov 01, 2008 9:15 am
by zephyr750
Hi there,

(using PHP Version 5.2.6 on windows apache2.2)
I am trying to call a method from a COM object to get an array of ids. I keep getting a com_exception of "Parameter 0: Type mismatch.". The code snip is as follows:

Code: Select all

 
//kernel object
$oSystem = new COM("DecisiveKernel.SystemContext");
//config area
$oConfig = $oSystem->Configuration;
 
$module_id_arr = new VARIANT();
 
try{
        $oConfig->GetModuleIDs($module_id_arr);
    }
    catch (com_exception $e)
    {
         echo "\n\nCom exception: \n";
         var_dump($e);
    }
 
the "GetModuleIDs()" method is the one that returns the type mismatch com_exception. other simple string pass-in methods from this com object work ok....

'com_print_typeinfo' returns the following for the method in question:
/* DISPID=1610809427 */
/* VT_I2 [2] */
function GetModuleIDs(
/* VT_PTR [26] [in][out] --> VT_SAFEARRAY [27] */ &$iIDs
)
{
}
I have tried many different ways of creating module_id_arr but nothing seems to work.

I can't get my head around the apparent need for a pointer to a safe array or how to define such an object/var in the php.

Any help or suggestions much appreciated.

Pete.