Bug #12925 Updated: PHP could not pass binary string to COM
| From: | phanto@php.net | Date: | Sun, 23 Sep 2001 11:03:20 +0000 |
| Subject: | Bug #12925 Updated: PHP could not pass binary string to COM | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-66385@lists.php.net to get a copy of this message | ||
ID: 12925
Updated by: phanto
Reported By: bin.yang@daytonrcs.com
Old Status: Open
Status: Closed
Bug Type: COM related
Operating System: W2K pro
PHP Version: 4.0.6
Previous Comments:
------------------------------------------------------------------------
[2001-08-27 12:00:01] bin.yang@daytonrcs.com
In conversion.c:
......
case IS_STRING:
var_arg->vt = VT_BSTR;
unicode_str = php_char_to_OLECHAR(pval_arg->value.str.val, pval_arg->value.str.len,
codepage);
var_arg->bstrVal = SysAllocString(unicode_str);
efree(unicode_str);
......
MSN document:
BSTR SysAllocString(OLECHAR FAR* sz);
Parameter :
sz: a zero terminated string to copy. The sz parameter must be a unicode string in 32-bit
applications, and an ANSI string in 16-bit applications.
......
What I did in my c++ file to send a binary string in c++
......
char tmpbuf[] = {0x00,0x20,.....0x11};
BSTR SEF = SysAllocStringByteLen(NULL,sizeof(tmpbuf));
memcpy(SEF,tmpbuf, sizeof(tmpbuf));
......
I can receive the binary string on the other end.
------------------------------------------------------------------------
[2001-08-27 11:53:32] bin.yang@daytonrcs.com
found the problem in conversion.c
------------------------------------------------------------------------
[2001-08-23 11:02:50] bin.yang@daytonrcs.com
Here is the PHP code.
$bp = new COM("AG2.Beepoj") or die("Unable to instanciate");
$bp-> beeeep(101,"\x0\x0\xff");
unset($bp);
The other end is a COM object, the beeeep method defined as
STDMETHODIMP Cbeepoj::Beeeep(int iDuration, BSTR b_str)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
// TODO: Add your implementation code here
::Beep(523,iDuration);
if(wcslen(b_str)!=0) AfxMessageBox((CString)b_str);
else AfxMessageBox("null string.");
return S_OK;
}
If I use $bp-> beeeep(101,"111111"); I will get 111111 displayed in a message box.
However, If the input is
$bp-> beeeep(101,"\x0\x0\xff"); The COM will say it is a
null string.
------------------------------------------------------------------------
Edit this bug report at http://bugs.php.net/?id=12925&edit=1