![]() | CString Basics |
This section describes common usage of the CString smart data type.
When implementing a method that should return a BSTR, either as [out, retval], [in, out] or [out], the BSTR should be allocated by the driver and freed by the client.
HRESULT Acme4321::IAcme4321Display_get_Text(BSTR* val) { HRESULT hr = S_OK; CString strText(_T("Hello world.")); // Allocate a BSTR *val = strText.AllocSysString(); return hr; }
More information is available in the MSDN documentation for CString.