// BSTR to C String BSTR bstrStart; bstrStart = GetBSTR(); TCHAR szFinal[255]; // direct conversion from BSTR to LPCTSTR only works // in Unicode _stprintf(szFinal, _T("%s"), (LPCTSTR)bstrStart); AfxMessageBox(szFinal); _bstr_t bstrIntermediate(bstrStart); // convert to // _bstr_t CString strFinal; // you have to go through _bstr_t to have it work in ANSI // and Unicode _stprintf(szFinal, _T("%s"), (LPCTSTR)bstrIntermediate); // Or, using MFC strFinal.Format(_T("%s"), (LPCTSTR)bstrIntermediate); AfxMessageBox(strFinal);
ネタ元