标签:
it |
三.CComBSTR
1.构造函数(看以下的代码即可)
// Appends "Wo" to "Hello " (4 bytes == 2 characters)
bstrPre.AppendBytes( reinterpret_cast(L"World!"), 4 );
// Displays a message box with text "Hello Wo"
::MessageBox(NULL, CW2CT(bstrPre), NULL, MB_OK);
CComBSTR
bstr1;
bstr1 =
"Bye";
OLECHAR* str =
OLESTR("ta ta");
CComBSTR
bstr2(wcslen(str));
wcscpy(bstr2.m_str,
str);
CComBSTR bstr3(5, OLESTR("Hello World")); // BSTR containing 'Hello',
CComBSTR bstr4(5,
"Hello
World");
CComBSTR bstr5(OLESTR("Hey there")); // BSTR containing 'Hey there',
CComBSTR bstr6("Hey
there");
CComBSTR
bstr7(bstr6);
2. HRESULT AppendBSTR(BSTR p ) throw( ); //将p附加到CComBSTR后面(字符串相加)
3. HRESULT AppendBytes(const char* lpsz,int nLen) throw( ); //同上,ANSI版
4. void Attach(BSTR src ) throw( ); //同_bstr_t中的
5. BSTR m_str; //这是属性,是与CComBSTR关联的BSTR
6.Length()://返回m_str的长度
7.Empty()://释放m_str
8. Detach()://同_bstr_t
9. ByteLength()返回m_str的字节数
10. BSTR Copy( ): //返回m_str的一个BSTR副本
11. HRESULT CopyTo(BSTR* pbstr ) throw( );
HRESULT CopyTo(VARIANT* pvarDest ) throw( );
//拷贝m_str的一个副本到所提供的地址中
12. ToLower()://将m_str转化为小写的
13. ToUpper()://将m_str转化为大写怕
14. HRESULT BSTRToArray(LPSAFEARRAY* ppArray ) throw( );
//将m_str拷贝到ppArray的安全数组中

