Tuesday, August 31, 2010

CString Methods at MSDN

http://msdn.microsoft.com/ja-jp/library/ms908314.aspx

Can use 'Find' to find a sub string in another string.


Copying a BSTR to a CString.

Note that the BSTR must be converted to a _bstr_t first.  If this is not done you only get the first character of the BSTR in the new CString.


BSTR GetBSTR() 
{     
_bstr_t bstr1(_T("This is the test string."));          
BSTR bstr;      bstr = bstr1.copy();      
   return bstr; 
}     
CComBSTR GetComBSTR() 
{     
CComBSTR bstr("This is the test string.");      
   return bstr; 
}   

void CVbsDlg::ShowBSTR(BSTR bstr) 
{     
_bstr_t bstrStart(bstr);           
CString s;      
s.Format(_T("%s"), (LPCTSTR)bstrStart);      AfxMessageBox(s);  
} 

No comments: