CComBSTR::Append

追加 lpsz 或 bstrSrc 的 BSTR 成员访问 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( );

参数

  • bstrSrc
    [in]追加的 CComBSTR 对象。

  • ch
    [in]追加的字符。

  • lpsz
    [in]一个零终止字符字符串追加。 可以通过 LPCOLESTR 重载传递给字符串Unicode或ANSI字符串传递 LPCSTR 版本。

  • nLen
    [in]中的字符数从追加的 lpsz 的。

返回值

在成功的S_OK,或者任何标准 HRESULT false值。

备注

ANSI字符串将转换为追加之前的Unicode。

示例

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;
}

要求

Header: atlbase.h

请参见

参考

CComBSTR 类

CComBSTR::AppendBSTR

CComBSTR::operator +=