How Can convert BSTR to LPCSTR OR vice versa!
-
CString does it for you - it can be constructed from a BSTR and AllocSysString returns a BSTR. Christian #include "std_disclaimer.h" People who love sausage and respect the law should never watch either one being made. The things that come to those who wait are usually the things left by those who got there first.
-
CString does it for you - it can be constructed from a BSTR and AllocSysString returns a BSTR. Christian #include "std_disclaimer.h" People who love sausage and respect the law should never watch either one being made. The things that come to those who wait are usually the things left by those who got there first.
Use _bstr_t to handle conversion from BSTR to const wchar_t*/const char*. _bstr_t is part of VC6.0's compiler COM support classes. Defined in . -- Venkat
-
Define USES_CONVERSION; at the top of the method implementation you are trying to do the conversion in. then use W2T void foo(BSTR bstrVariable) { USES_CONVERSION; // conversion is done to the stack so don't delete on function exit // and don't use pointer outside of method. LPCTSTR pcstrVariable = W2T(bstrVariable); // TODO: do work with string. } Cheers, -Erik ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ My thoughts are my own and reflect on no other.