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 BSTRtom_str. | 
| CComBSTR::AppendBytes | Appends a specified number of bytes to m_str. | 
| CComBSTR::ArrayToBSTR | Creates a BSTRfrom the first character of each element in the safearray and attaches it to theCComBSTRobject. | 
| CComBSTR::AssignBSTR | Assigns a BSTRtom_str. | 
| CComBSTR::Attach | Attaches a BSTRto theCComBSTRobject. | 
| CComBSTR::BSTRToArray | Creates a zero-based one-dimensional safearray, where each element of the array is a character from the CComBSTRobject. | 
| CComBSTR::ByteLength | Returns the length of m_strin bytes. | 
| CComBSTR::Copy | Returns a copy of m_str. | 
| CComBSTR::CopyTo | Returns a copy of m_strvia an [out] parameter | 
| CComBSTR::Detach | Detaches m_strfrom theCComBSTRobject. | 
| CComBSTR::Empty | Frees m_str. | 
| CComBSTR::Length | Returns the length of m_str. | 
| CComBSTR::LoadString | Loads a string resource. | 
| CComBSTR::ReadFromStream | Loads a BSTRobject from a stream. | 
| CComBSTR::ToLower | Converts the string to lowercase. | 
| CComBSTR::ToUpper | Converts the string to uppercase. | 
| CComBSTR::WriteToStream | Saves m_strto a stream. | 
ComBSTR operators
| Name | Description | 
|---|---|
| CComBSTR::operator BSTR | Casts a CComBSTRobject to aBSTR. | 
| CComBSTR::operator ! | Returns trueorfalse, depending on whetherm_strisNULL. | 
| CComBSTR::operator != | Compares a CComBSTRwith a string. | 
| CComBSTR::operator & | Returns the address of m_str. | 
| CComBSTR::operator += | Appends a CComBSTRto the object. | 
| CComBSTR::operator < | Compares a CComBSTRwith a string. | 
| CComBSTR::operator = | Assigns a value to m_str. | 
| CComBSTR::operator == | Compares a CComBSTRwith a string. | 
| CComBSTR::operator > | Compares a CComBSTRwith 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.
 
 