views:

687

answers:

2

when reading data through serial port

VARIANT data;
BSTR k;
if(m_mscom.GetCommEvent() == 2)
{
 data = m_mscom.GetInput();  
 k = data.bstrVal;
    }

What is BSTR k; and what do you mean k=data.bstrVal? What is bstrVal?

A: 

BSTR is a pointer to unicode character(just character type that can hold unicode character). data.bstrVal converts variant to BSTR.

yesraaj
+1  A: 

BSTR and VARIANT are data types used in COM. Actually, VARIANT is a container that may hold any COM data type.

In your case, GetInput() returns VARIANT containing a buffer as BSTR, so bstrVal has to be used to retrieve it.

Dmitry Khalatov