问题描述
我正在调用一个 COM 对象方法,该方法在我的 PHP 代码中返回类型为 8209 的数组变体对象.
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
我希望最终将转换后的 VT_VARIANT 对象作为另一个 COM 对象方法的值传递,该方法要求其输入为 VT_VARIANT[12].
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].
我通过发出以下命令将 $com_VArray 转换为 VT_VARIANT 对象变体类型
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);
然后我收到以下错误
致命错误:未捕获的异常 'com_exception' 带有消息变体类型转换失败:类型不匹配."在 C:xampphtdocswaterCompany eservoir.php:110 堆栈跟踪 #0 C:xampphtdocswaterCompany eservoir.php(110): variant_cast(Object(variant),12)#1{main} 抛出在第 110 行的 C:xampphtdocswaterCompany eservoir.php 中.
Fatal error: Uncaught exception 'com_exception' with message 'Variant type conversion failed: Type mismatch.' in C:xampphtdocswaterCompany eservoir.php:110 Stack trace #0 C:xampphtdocswaterCompany eservoir.php(110): variant_cast(Object(variant),12)#1{main} thrown in C:xampphtdocswaterCompany eservoir.php on line 110.
我在这里阅读了有关 variant_cast 的更多信息 http://php.net/manual/en/function.variant-set-type.php 但我没有取得太大进展.
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.
我使用的是 PHP 5.5.11.
I am using PHP 5.5.11.
推荐答案
8209 是 0x2011,表示 VT_UI1 元素的数组.
8209 is 0x2011 that signals an array of VT_UI1 elements.
当你想转换它时,你需要创建一个 Variants 数组并将旧类型的每个元素复制到其中.复制内容时,您可以将每个 VT_UI1 元素转换为 VT_VARIANT 类型.
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.
不允许也永远不允许强制转换数组.试着学习VARIANTs的基础
It is not and never allowed to cast arrays. Just try to learn the basisc of VARIANTs
这篇关于如何将 8209 数组对象变量转换为 VT_VARIANT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)