How to convert 8209 array object variant to VT_VARIANT
Asked Answered
M

1

0

I am calling a COM object method that returns an array variant object of type 8209 in my PHP code.

$com_VArray = $com_Object->objectMethod; //Is a 8209 variant object

I want in the end to pass the converted VT_VARIANT object as a value for another COM object method which requires its input to be VT_VARIANT[12].

I am converting $com_VArray to a VT_VARIANT object variant type by issuing the following

$obj_VT_VARIANT = variant_cast($com_VArray, VT_VARIANT);

But then I get this following error

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

I have done some more reading on variant_cast here http://php.net/manual/en/function.variant-set-type.php but I have not made much significant headways.

I am using PHP 5.5.11.

Morbid answered 17/2, 2017 at 10:30 Comment(9)
Where does vbscript fit into this?Inhambane
You already retrieved a Variat containing a VT_UI1. There is no Variant of type VT_VARIANT you may have a pointer to a variant (VT_BYREF) or a variant array.Intermingle
xMRi please elaborate further why you say that. See msdn.microsoft.com/en-us/library/windows/desktop/… My application's object method requires a VT_VARIANT.Morbid
You are wrong. VT_UI1 describes a variant containing a unsigend BYTE.Intermingle
@JosephMwema why do you keep referencing VBScript?? What does that have to do with this issue?, please explain.Inhambane
@Intermingle I know that VT_UI1 is 1 byte unsigned integer. I am going to restructure the question more clearly then.Morbid
@Lankymart I am removing it then.Morbid
I reframed my question again. I hope it is now easier to understand & interpret what I am looking for and I could also explain further where it is not clear.Morbid
8209 is 0x2011 that is an array of VT_UI1 elements. When you want to convert it, Create an array of Variants and copy each element into it. It is not allowed to cast arrays. Just try to learn the basisc of VARIANTsIntermingle
I
0

8209 is 0x2011 that signals an array of VT_UI1 elements.

When you want to convert it, you need to create an array of Variants and copy each element of the old type into it. When you copy the contents you can cast each VT_UI1 element into an VT_VARIANT type.

It is not and never allowed to cast arrays. Just try to learn the basisc of VARIANTs

Intermingle answered 18/2, 2017 at 8:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.