EQuestionAnswers.com Computer/Electronics Questions and Answers
C, C++, VC++, COM/DCOM, DLL and more
#Login #Sign up  Facebook Twitter TGoogle+
 

#Previous question #Index of COM/DCOM Questions #Next question

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

NameDescription
CComBSTR::AppendAppends a string to m_str.
CComBSTR::AppendBSTRAppends a BSTR to m_str.
CComBSTR::AppendBytesAppends a specified number of bytes to m_str.
CComBSTR::ArrayToBSTRCreates a BSTR from the first character of each element in the safearray and attaches it to the CComBSTR object.
CComBSTR::AssignBSTRAssigns a BSTR to m_str.
CComBSTR::AttachAttaches a BSTR to the CComBSTR object.
CComBSTR::BSTRToArrayCreates a zero-based one-dimensional safearray, where each element of the array is a character from the CComBSTR object.
CComBSTR::ByteLengthReturns the length of m_str in bytes.
CComBSTR::CopyReturns a copy of m_str.
CComBSTR::CopyToReturns a copy of m_str via an [out] parameter
CComBSTR::DetachDetaches m_str from the CComBSTR object.
CComBSTR::EmptyFrees m_str.
CComBSTR::LengthReturns the length of m_str.
CComBSTR::LoadStringLoads a string resource.
CComBSTR::ReadFromStreamLoads a BSTR object from a stream.
CComBSTR::ToLowerConverts the string to lowercase.
CComBSTR::ToUpperConverts the string to uppercase.
CComBSTR::WriteToStreamSaves m_str to a stream.

ComBSTR operators

NameDescription
CComBSTR::operator BSTRCasts a CComBSTR object to a BSTR.
CComBSTR::operator !Returns true or false, depending on whether m_stris 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.

You have viewed 1 page out of 66. Your COM/DCOM learning is 0.00% complete. Login to check your learning progress.

 Vote 0

Similar topics related to this section

# COM DCOM Interview Questions and Answers :: ALL Interview .com
# COM DCOM - COM DCOM Interview Questions
# COM interview questions | TechInterviews
# COM Interview Questions - CodeProject
# Com Dcom Interview Questions - Com and Dcom in Asp Net
# ATL Interview Questions and Answers :: ALL Interview .com
# ActiveX Interview Questions and Answers :: ALL Interview .com

* #1 webmaster Mon 28 Apr/2014 23:22:19(GMT)  Like 0 Unlike 0

Dear Users,

We are pleased to inform you that a forum/blog has been incorporated with www.mybestnotes.co.in. You are welcomed to add your comments, requests, codes, solutions and feedback to it. Please login(if already a member) or signup(for free) to avail to this facility.

Regards,
Webmaster

Your message goes here:

Name:Guest
Email:anonymous@unknown.com
My Post:*
Secutiry Code: ******  *
Preview this compose before posting this in discussion forum.
 
Note:
  1. Use [Sxx] code to show smiles. Example [S02]
  2. Use [URL ], example [URL http://www.google.com/]
  3. To display code or un formatted text use [CODE] [/CODE]. Example: [CODE] printf("Hello world"); [/CODE]
 [S01]   [S02]   [S03]   [S04]   [S05]   [S06]   [S07]   [S08] 
 [S09]   [S10]   [S11]   [S12]   [S13]   [S14]   [S15]   [S16] 
 [S17]   [S18]   [S19]   [S20]   [S21]   [S22]   [S23]   [S24] 

Note: Only members are allowed, * fields are mandatory.