I am trying to call a CAPICOM object that requires BSTR as its input and output. My existing data is held in a char array, (char szMyExistingData[200]). Does anyone know how to convert a char array to BSTR and back again without using the .Net framework
Example Code
char
szMyExistingData[200];BSTR encodeData;
BSTR decodeData;
// encodeData=szMyExistingData // Some way to do this
CAPICOM::IUtilitiesPtr b64(__uuidof(CAPICOM::Utilities));
decodeData = b64->Base64Decode(encodeData);
// szMyExistingData=decodeData // Some way to do this

Converts from Char Array to BSTR and back
Gergely Meszaros
Thank you this is very helpfull.
I have managed to get it working OK, one outstanding issue, CAPICOM Utilities Base64Encode encodes multibyte char's, do you know of any way to get it to encode single (Ascii) char's
Cush
You can use the ATL T-macros
USES_CONVERSION;
strcpy(szMyExistingData,OLE2A(decodeData));
You can simply use the CString conversion
CString myString(decodeData);
strcpy(szMyExistingData,myString);
Or you can use wcsrtombs (see docs in the MSDN).