PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
kaisellgren
DevNet Resident
Posts: 1675 Joined: Sat Jan 07, 2006 5:52 am
Location: Lahti, Finland.
Post
by kaisellgren » Mon May 25, 2009 6:45 am
Hi,
How would I construct an array of bytes with VARIANT (
http://fi.php.net/manual/en/class.variant.php ) for a .NET module I have?
Code: Select all
$arr = array();
$v = new VARIANT($arr,VT_ARRAY | VT_UI1);
I have tried this (and plenty of other approaches), but it/they didn't work: Fatal error: Uncaught exception 'com_exception' with message 'Variant type conversion failed: Type mismatch.
Does anyone have ideas?
Weirdan
Moderator
Posts: 5978 Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine
Post
by Weirdan » Mon May 25, 2009 1:22 pm
I guess you either use variant or byte array - they are not the same. Have you tried passing simple php string where byte array is expected?
kaisellgren
DevNet Resident
Posts: 1675 Joined: Sat Jan 07, 2006 5:52 am
Location: Lahti, Finland.
Post
by kaisellgren » Mon May 25, 2009 1:49 pm
Weirdan wrote: I guess you either use variant or byte array - they are not the same. Have you tried passing simple php string where byte array is expected?
What is a byte array in PHP? An array that has bytes? Well that does not work either.
Weirdan
Moderator
Posts: 5978 Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine
Post
by Weirdan » Mon May 25, 2009 2:16 pm
kaisellgren wrote: What is a byte array in PHP?
The closest php has to byte array is string, plain old string.
kaisellgren
DevNet Resident
Posts: 1675 Joined: Sat Jan 07, 2006 5:52 am
Location: Lahti, Finland.
Post
by kaisellgren » Mon May 25, 2009 2:23 pm
Weirdan wrote: kaisellgren wrote: What is a byte array in PHP?
The closest php has to byte array is string, plain old string.
It has the same results: Fatal error: Uncaught exception 'com_exception' with message 'Variant type conversion failed: Type mismatch.
Weirdan
Moderator
Posts: 5978 Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine
Post
by Weirdan » Mon May 25, 2009 6:40 pm
Well, from what I read on the web your best bet would be VT_BYREF|VT_UI1.
kaisellgren
DevNet Resident
Posts: 1675 Joined: Sat Jan 07, 2006 5:52 am
Location: Lahti, Finland.
Post
by kaisellgren » Mon May 25, 2009 6:54 pm
Weirdan wrote: Well, from what I read on the web your best bet would be VT_BYREF|VT_UI1.
Produces the same mismatch error. =/
Weirdan
Moderator
Posts: 5978 Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine
Post
by Weirdan » Mon May 25, 2009 7:12 pm
Code: Select all
$arr = "\0\1\2";
$v = new VARIANT($arr, VT_ARRAY|VT_UI1);
seems to not throw any exceptions, don't know if it actually what is needed.
kaisellgren
DevNet Resident
Posts: 1675 Joined: Sat Jan 07, 2006 5:52 am
Location: Lahti, Finland.
Post
by kaisellgren » Tue May 26, 2009 7:28 am
Weirdan wrote: Code: Select all
$arr = "\0\1\2";
$v = new VARIANT($arr, VT_ARRAY|VT_UI1);
seems to not throw any exceptions, don't know if it actually what is needed.
Fatal error: Uncaught exception 'com_exception' with message 'Error [0x80070057] The parameter is incorrect.
The reason why I need this is, because a component requires it.
Take a look at this:
Code: Select all
$ie = new COM("InternetExplorer.Application");
$ie->Visible = true;
$ie->Height = 500 ;
$ie->Width = 700 ;
$post = array (ord('p'),ord('='),ord('1')) ;
$v = new VARIANT($post, VT_ARRAY|VT_UI1);
//postdata need to be array of byte
$ie->Navigate2("http://host/web/echo_request.php",0,'',$v);