This function creates a new BSTR that contains a specified number of characters from an old BSTR, and frees the old BSTR.

HRESULT SysReAllocStringLen(
  BSTR FAR* pbstr, 
  OLECHAR FAR* pch, 
  unsigned int cch 


  • pbstr
    [out] Pointer to a variable that contains a BSTR.
  • pch
    [in] Pointer to cch characters to copy, or NULL to keep the string uninitialized.
  • cch
    [in] Number of characters to copy from pch. A null character is placed afterward, allocating a total of cch+1 characters.

Return Values

Returns an HRESULT value.


The SysReAllocStringLen function allocates a new string, copies cch characters from the passed string into it, and then appends a null character. Frees the BSTR referenced currently by pbstr, and resets pbstr to point to the new BSTR. If pch is NULL, a string of length cch is allocated but not initialized.

The pch string can contain embedded null characters and does not need to end with a NULL.

Windows CE supports only Unicode strings.

Passing invalid (and under some circumstances NULL) pointers to this function causes an unexpected termination of the application.


OS Versions: Windows CE 2.0 and later.
Header: Oleauto.h.
Link Library: Oleaut32.lib.

See Also


Last updated on Wednesday, April 13, 2005

© 2005 Microsoft Corporation. All rights reserved.