Share via


CComBSTR::Append

Appends either lpsz or the BSTR member of bstrSrc to m_str.

HRESULT Append(
   const CComBSTR& bstrSrc 
) throw( );
HRESULT Append(
   wchar_t ch
) throw( );
HRESULT Append(
   char ch
) throw( );
HRESULT Append(
   LPCOLESTR lpsz 
) throw( );
HRESULT Append(
   LPCSTR lpsz 
) throw( );
HRESULT Append(
   LPCOLESTR lpsz,
   int nLen 
) throw( );

Parameters

  • bstrSrc
    [in] A CComBSTR object to append.

  • ch
    [in] A character to append.

  • lpsz
    [in] A zero-terminated character string to append. You can pass a Unicode string via the LPCOLESTR overload or an ANSI string via the LPCSTR version.

  • nLen
    [in] The number of characters from lpsz to append.

Return Value

S_OK on success, or any standard HRESULT error value.

Remarks

An ANSI string will be converted to Unicode before being appended.

Example

enum { urlASP, urlHTM, urlISAPI } urlType;
urlType = urlASP;

CComBSTR bstrURL = OLESTR("http://SomeSite/");
CComBSTR bstrDEF = OLESTR("/OtherSite");
CComBSTR bstrASP = OLESTR("default.asp");

CComBSTR bstrTemp;
HRESULT hr;

switch (urlType)
{
case urlASP:
   // bstrURL is 'http://SomeSite/default.asp'
   hr = bstrURL.Append(bstrASP);
   break;

case urlHTM:
   // bstrURL is 'http://SomeSite/default.htm'
   hr = bstrURL.Append(OLESTR("default.htm"));
   break;

case urlISAPI:
   // bstrURL is 'http://SomeSite/default.dll?func'
   hr = bstrURL.Append(OLESTR("default.dll?func"));
   break;

default:
   // bstrTemp is 'http://'
   hr = bstrTemp.Append(bstrURL, 7);
   // bstrURL is 'http://OtherSite'
   if (hr == S_OK)
       hr = bstrTemp.Append(bstrDEF);
   bstrURL = bstrTemp;

   break;
}

Requirements

Header: atlbase.h

See Also

Reference

CComBSTR Class

CComBSTR::AppendBSTR

CComBSTR::operator +=

Other Resources

CComBSTR Members