Use thi9s code:
//------------------------//
// Convert BSTR to char * //
//------------------------//
inline char* ConvertBSTRToString(BSTR pSrc)
{
if(!pSrc) return NULL;
DWORD cb,cwch = ::SysStringLen(pSrc);//convert even embeded NULL
char \*szOut = NULL;
if(cb = ::WideCharToMultiByte(CP\_ACP, 0, pSrc, cwch + 1, NULL, 0, 0, 0))
{
szOut = new char\[cb\];
if(szOut)
{
szOut\[cb - 1\] = '\\0';
if(!::WideCharToMultiByte(CP\_ACP, 0, pSrc, cwch + 1, szOut, cb, 0, 0))
{
delete \[\]szOut;//clean up if failed;
szOut = NULL;
}
}
}
return szOut;
};
soptest