
Originally Posted by
Codeplug
Doesn't compile.
"CComB
STR" - and it doesn't have an "operator LPCSTR".
Code:
#include <atlbase.h>
#include <iostream>
using namespace std;
int main()
{
CComBSTR code(_T("Hello World!"));
char c = static_cast<char>(*code.m_str);
cout << c << endl;
return 0;
}//main
gg
Looks like the msdn link I gave was incorrect.
No biggie - just use the string conversion macro.
Code:
CComBSTR code( _T("Hello World!") );
USES_CONVERSION;
LPTSTR sz = OLE2T( code );
TCHAR c = sz[0];
The above works in ANSI and UNICODE.
When working in Windows code, any code that uses 'char' makes me cringe ('cuz I now it's going to be a pain if I ever need to port the code to UNICODE).