SysAllocStringLen Function

Allocates a new string, copies cch characters from the passed string into it, and then appends a null terminator.

BSTR SysAllocStringLen(
  const OLECHAR   *pch,
  unsigned int  cch
);

pch

A pointer to cch characters to be copied. If pch is NULL, a new string is allocated that contains only the null terminator. The caller is responsible for initializing the first cch characters of the string.

cch

The number of characters to be copied from pch. A null character is placed afterwards, allocating a total of cchplus one characters.

Points to a copy of the string, or NULL if insufficient memory exists.

The pch string can contain embedded null characters and does not need to end with a NULL. Free the returned string later with SysFreeString. If pch is not NULL, then the memory allocated to pch must be at least cch characters long.

NoteNote

This function does not convert a char * string into a Unicode BSTR.

Show:
© 2014 Microsoft