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 ?
BSTR k;
k=data.bstrVal
bstrVal
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.
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.