How to pass a variant object type 16396 in a COM method that requires an input value of a VT_VARIANT [12]

这一生的挚爱 提交于 2019-12-13 12:23:11

问题


I have in my PHP code, a COM object '$com_myObject' with a method 'myObjectMethod' which after I run

com_print_type info($com_myObject);

on it, it shows that it has the method 'myObjectMethod' declared as shown below

myObjectMethod(/* VT_VARIANT [12] [in] */ $RawData) { /* Processes entered object data */ }

In my code I am having another function return a variant object '$myInputObject' of type value 16396. I plan to use '$myInputObject' as the input value for 'myObjectMethod' method.

print variant_get_type($myInputObject);  //returns 16396

I am retrieving the value for '$myInputObject' as shown below from this other COM function i.e 'ofunction' .

$myInputObject = $com_myObject->ofunction;

I am assuming that from 'myObjectMethod' method declaration I am supposed to pass a VT_VARIANT object i.e. a variant type 12 but what my other function 'ofunction' returns which is supposed to be the input value for 'myObjectMethod' is a variant object of type 16396.

I have tried to convert the variant object of type 16396 to a variant object of type 12 as shown below

$com_myObject->myObjectMethod(variant_cast($myInputObject, VT_VARIANT));

but I am getting the following error.

Fatal error: Uncaught exception 'com_exception' with message 'Variant type conversion failed: Type mismatch.' in C:\xampp\htdocs\waterCompany\reservoir.php:125 Stack trace #0 C:\xampp\htdocs\waterCompany\reservoir.php(125): variant_cast(Object(variant),12)#1{main} thrown in C:\xampp\htdocs\waterCompany\reservoir.php on line 125.

来源:https://stackoverflow.com/questions/42321017/how-to-pass-a-variant-object-type-16396-in-a-com-method-that-requires-an-input-v

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!