BSTR AnsiToBSTR( LPTSTR pchData )<br>{<br> // Helper function derived from source of CString::AllocSysString()<br> BSTR bstr = NULL;<br>#if defined(_UNICODE) ¦¦ defined(OLE2ANSI)<br> bstr = ::SysAllocStringLen(pchData, wcslen( pchData ) );<br>#else<br> int nLen = MultiByteToWideChar(CP_ACP, 0, pchData,<br> strlen( pchData ), NULL, NULL);<br> bstr = ::SysAllocStringLen(NULL, nLen);<br> if (bstr == NULL)<br> return NULL;<br> MultiByteToWideChar(CP_ACP, 0, pchData, <br> strlen( pchData ), bstr, nLen);<br>#endif<br><br> return bstr;<br>}<br>