SysAllocString

BSTR SysAllocString( 
  OLECHAR FAR*  sz  
);
 

Allocates a new string and copies the passed string into it. Returns Null if there is insufficient memory, and if Null, Null is passed in.

Parameter

sz
A zero-terminated string to copy. The sz parameter must be a Unicode string in 32-bit applications, and an ANSI string in 16-bit applications.

Return Value

If successful, points to a BSTR containing the string. If insufficient memory exists or sz was Null, returns Null.

Comments

You can free strings created with SysAllocString using SysFreeString.

Example

inline void CStatBar::SetText(OLECHAR FAR* sz)
{
    SysFreeString(m_bstrMsg);
    m_bstrMsg = SysAllocString(sz);
}

QuickInfo

  Windows NT: Use version 3.1 and later.
  Windows: Use Windows 95 and later.
  Header: Declared in oleauto.h.
  Import Library: Link with oleaut32.lib.