MSComm, Variant and ByteArray...

Hi, as many other peoples, I've got problems with MSComm and sending / Receiving null character. I solved my sending problem by using a CByteArray. I want to do the same thing when receiving, so I need to convert a COleVariant to a ByteArray. I don't know mutch about the subject but I've seen examples and I try to do the same.

Here is the code I use:

CByteArray InArray;
COleVariant VarIn;
void* pArrayData;

VarIn=m_MSComm2.GetInput();

InArray.SetSize(VarIn.parray->rgsabound[0].cElements);
SafeArrayAccessData(VarIn.parray, &pArrayData);
memcpy(InArray.GetData(), pArrayData, InArray.GetSize());

SafeArrayUnaccessData(VarIn.parray);

When I trace the program, I see as expected, 3 Bytes in VarIn. On the other hand, "VarIn.parray->rgsabound[0].cElements" returns junk (-1414812757 which is quite different from 3).

Does anyone knows what I'm doing wrong ?
[962 byte] By [Megabuffer] at [2007-11-18 22:12:27]
# 1 Re: MSComm, Variant and ByteArray...
I found the answer by myself :

Binary mode was not set.
Megabuffer at 2007-11-11 1:04:43 >