Bug #11658: COM passing by refrence
| From: | Crawley | Date: | Wed, 26 Sep 2001 12:51:09 +0000 |
| Subject: | Bug #11658: COM passing by refrence | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-66647@lists.php.net to get a copy of this message | ||
[2001-07-05 20:43:44] phanto@php.net
but by definition every interface derived from IDispatch that should support
references
must expect VARIANT *var instead of <anothertype> *var . am i wrong ?
[2001-07-23 13:50:06] phanto@php.net
doesn't work with VBScript either and due to the provided typelib i assume
that it is a
user (component) error.
-harald.
Ive played around with this, and can tell you that a IDispatch interface can
have ( pass by ref ) args that are of any type ( BSTR *, long *, etc ).
These can be accesed without using a typelib from both VBScript and Perl but
not php.
For example, given an interface like this
HRESULT test( [ out, ref ] unsigned char *n );
I can call that from PERL like
use Win32::OLE;
use Win32::OLE::Variant;
$obj = Win32::OLE->new( "comobjectname" );
$n = Variant( VT_UI1 | VT_BYREF, 0 );
$obj->test( $n );
and in VBScript its called like this
var obj = Server.CreateObject( "comobjectname" )
var n = 0
obj.test( n )
you dont need to have 'n' defined as a VARIANT, as in VBScript ALL variables
are VARIANT's.
Note that both these DONT use a typelib.
Given that you would expect this to work in php
$obj = new COM( "comobjectname" );
$n = new VARIANT( 0, VT_UI1 | VT_BYREF );
$obj->test( $n );
But you get this error:
Warning: Invoke() failed: Type mismatch in <filename> on line <line>
I understand from what Ive read that if the interface was defined with the
arg as type VARIANT *, it would work.....
BUT if you wish to be able to support existing interfaces ( which dont use
type VARIANT * ) and to provide the same 'level' of COM support as VBScript
and Perl. You should be able to call the above interface with the ( above )
php code.
Rich
P.S. when is php 4.0.7 due out ?