I'm using Comm32 (an activeX control) to get data coming through serial port using the method GetInput(). This method returns a _variant_t, so I need to convert it to an array of unsigned char's.
When serial port is configured to TextMode (this is data input is interpreted as String), converting the Variant to a BSTR and then to a CString works as expected (code not writed by me):
_variant_t x = m_comm32.GetInput();
CString cs = x.bstrVal;
However, as data sent through serial port is actually binary data, when configuring comm32 to interpret data as binary the sample code above doesn't give me the valid data. So I think I need to convert it to another format (unsigned char array maybe? that's somehting I want to test).
My problem is I'm getting crazy as I cannot find any detailed info about how to convert data from a VARIANT structure. How can I convert the variant to an unsigned char array??