This function allocates a new string and copies the passed string into it. SysAllocString returns null if there is insufficient memory or if a null pointer is passed in.
At a Glance
Header file: | Oleauto.h |
Windows CE versions: | 2.0 and later |
Syntax
BSTR SysAllocString(OLECHAR FAR * sz);
Parameters
sz
Null-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 Values
A pointer to a BSTR that contains the string indicates success. NULL indicates that insufficient memory exists or the sz parameter was NULL.
Example
inline void CStatBar::SetText(OLECHAR FAR* sz)
{
SysFreeString(m_BSTRMsg);
m_BSTRMsg = SysAllocString(sz);
}
Remarks
Windows CE supports only Unicode strings.
Passing into this function any invalid and, under some circumstances, NULL pointers will result in unexpected termination of the application.
You can free strings created with SysAllocString using SysFreeString.
Example
inline void CStatBar::SetText(OLECHAR FAR* sz)
{
SysFreeString(m_BSTRMsg);
m_BSTRMsg = SysAllocString(sz);
}