Page 1 of 1

An array of bytes?

Posted: Mon May 25, 2009 6:45 am
by kaisellgren
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?

Re: An array of bytes?

Posted: Mon May 25, 2009 1:22 pm
by Weirdan
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?

Re: An array of bytes?

Posted: Mon May 25, 2009 1:49 pm
by kaisellgren
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.

Re: An array of bytes?

Posted: Mon May 25, 2009 2:16 pm
by Weirdan
kaisellgren wrote:What is a byte array in PHP?
The closest php has to byte array is string, plain old string.

Re: An array of bytes?

Posted: Mon May 25, 2009 2:23 pm
by kaisellgren
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.

Re: An array of bytes?

Posted: Mon May 25, 2009 6:40 pm
by Weirdan
Well, from what I read on the web your best bet would be VT_BYREF|VT_UI1.

Re: An array of bytes?

Posted: Mon May 25, 2009 6:54 pm
by kaisellgren
Weirdan wrote:Well, from what I read on the web your best bet would be VT_BYREF|VT_UI1.
Produces the same mismatch error. =/

Re: An array of bytes?

Posted: Mon May 25, 2009 7:12 pm
by Weirdan

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.

Re: An array of bytes?

Posted: Tue May 26, 2009 7:28 am
by kaisellgren
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);