How to convert OLECHAR*
to CString
in VC++ ?
Asked
Active
Viewed 2,476 times
1

Rohit Vipin Mathews
- 11,629
- 15
- 57
- 112

Swapnil Gupta
- 8,751
- 15
- 57
- 75
1 Answers
2
OLECHAR*
is the same as BSTR
. You can convert to CString
like this (sorry about formatting, I have lost the code
icon for now).
OLECHAR* value;
BSTR (bstrValue(value));
_bstr_t tmp(bstr, FALSE); //wrap the BSTR
CString cs(static_cast<const char*>(tmp)); //convert it

Steve Townsend
- 53,498
- 9
- 91
- 140
-
A `BSTR` is NULL-terminated and points to the beginning of the string. So could you just do `CString cs(value);`? – Nate Dec 21 '10 at 17:24
-
Is OLECHAR* the same as BSTR? I was under the impression that OLECHAR* is the same as WCHAR * which is the same as wchar_t. BSTR's are more restrictive than an array of wchar_t – SJHowe Oct 16 '19 at 18:07