Serial port communication in VC ++

when reading data through a 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 it bstrVal

?

+1


source to share


2 answers


BSTR and VARIANT are used data types in COM. In fact, VARIANT is a container that can contain any COM data type.



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

+1


source


BSTR is a pointer to a Unicode character (only the type of character that can contain a Unicode character). data.bstrVal converts the variant to BSTR.



0


source







All Articles