CStrint to BSTR CString str = "CString to BSTR" BSTR b_str = str.AllocSysString(); // do something ::SysFreeString(b_str); BSTR to CString CString convert(BSTR b) { CString s; if(b == NULL) return s; // empty for NULL BSTR #ifdef UNICODE s = b; #else LPSTR p = s.GetBuffer(SysStringLen(b) + 1); ::WideCharToMultiByte(CP_ACP, // ANSI Code Page 0, // no flags b, // source widechar string -1, // assume NUL-terminated p, // target buffer SysStringLen(b)+1, // target buffer length NULL, // use system default char NULL); // don't care if default used s.ReleaseBuffer(); #endif return s; }