ASCII strings are used in client and servers. However wide character strings are recomended to support verious local languages. DCOM parameters of strings are always BSTRs. So there is always a need to convert ASCII to wide char and then wide char to BSTRs. ATL framework has a set of helper macros to convert between these type of strings.
Mecro notations
Notation | Description |
A | ANSI character string. |
W | Unicode character string. |
T | Generic character string (equivalent to W when _UNICODE is defined, equivalent to A otherwise). |
OLE | OLE character string (equivalent to W). |
Mecro names
A2BSTR | OLE2A | T2A | W2A |
A2COLE | OLE2BSTR | T2BSTR | W2BSTR |
A2CT | OLE2CA | T2CA (Deprecated. Use T2CA_EX or CT2CA instead.) | W2CA |
A2CW | OLE2CT | T2COLE | W2COLE |
A2OLE | OLE2CW | T2CW | W2CT |
A2T | OLE2T | T2OLE | W2OLE |
A2W | OLE2W | T2W | W2T |
ComBSTR class
ComBSTR is one helper class provided by MFC/ATL to convert UNICODE string to BSTR and vice versa. It has verious public methods and operators for managing and manipulating BSTRs in COM servers and client.
ComBSTR methods
Name | Description |
---|---|
CComBSTR::Append | Appends a string to m_str . |
CComBSTR::AppendBSTR | Appends a BSTR to m_str . |
CComBSTR::AppendBytes | Appends a specified number of bytes to m_str . |
CComBSTR::ArrayToBSTR | Creates a BSTR from the first character of each element in the safearray and attaches it to the CComBSTR object. |
CComBSTR::AssignBSTR | Assigns a BSTR to m_str . |
CComBSTR::Attach | Attaches a BSTR to the CComBSTR object. |
CComBSTR::BSTRToArray | Creates a zero-based one-dimensional safearray, where each element of the array is a character from the CComBSTR object. |
CComBSTR::ByteLength | Returns the length of m_str in bytes. |
CComBSTR::Copy | Returns a copy of m_str . |
CComBSTR::CopyTo | Returns a copy of m_str via an [out] parameter |
CComBSTR::Detach | Detaches m_str from the CComBSTR object. |
CComBSTR::Empty | Frees m_str . |
CComBSTR::Length | Returns the length of m_str . |
CComBSTR::LoadString | Loads a string resource. |
CComBSTR::ReadFromStream | Loads a BSTR object from a stream. |
CComBSTR::ToLower | Converts the string to lowercase. |
CComBSTR::ToUpper | Converts the string to uppercase. |
CComBSTR::WriteToStream | Saves m_str to a stream. |
ComBSTR operators
Name | Description |
---|---|
CComBSTR::operator BSTR | Casts a CComBSTR object to a BSTR . |
CComBSTR::operator ! | Returns true or false , depending on whether m_str is NULL . |
CComBSTR::operator != | Compares a CComBSTR with a string. |
CComBSTR::operator & | Returns the address of m_str . |
CComBSTR::operator += | Appends a CComBSTR to the object. |
CComBSTR::operator < | Compares a CComBSTR with a string. |
CComBSTR::operator = | Assigns a value to m_str . |
CComBSTR::operator == | Compares a CComBSTR with a string. |
CComBSTR::operator > | Compares a CComBSTR with a string. |
About our authors: Team EQA
You have viewed 1 page out of 67. Your COM/DCOM learning is 0.00% complete. Login to check your learning progress.