MAKE_MULTIBYTESTRING

MAKE_MULTIBYTESTRING(name, arg)

Parameters

name

Variable name of the allocated ANSI string pointer.

arg

 Source string, must be a BSTR or a WCHAR*.

Comments

Use this macro to convert a wide string to an ANSI multibyte string. The buffer returned by this macro is automatically deallocated when it goes out of scope.

Example

   // Convert BSTR to ANSI string buffer.
   // Must check for NULL allocation.
   //
   MAKE_MULTIBYTESTRING(szText, bstrText)
   if (NULL == szText) return E_OUTOFMEMORY;

   // Use allocated ANSI string.
   //
   SetWindowText(m_hwnd, szText);

   //
   // szText will be freed when it loses scope.
   //