Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.


Windows Mobile 6.5
A version of this page is also available for

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

HRESULT SysReAllocStringLen(
  BSTR FAR* pbstr,
  unsigned int cch 


[out] Pointer to a string.


[in] Pointer to cch characters to copy, or NULL to keep the string uninitialized.


[in] Number of characters to copy from pch.A null character is placed afterward, allocating a total of cch+1 characters.

Returns an HRESULT value.

The SysReAllocStringLen function does the following:

  • Allocates a new string
  • Copies cch characters from the passed string into it
  • Appends a null character
  • Frees the BSTR referenced by pbstr
  • 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.

Only Unicode strings are supported.

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

Windows Embedded CEWindows CE 2.0 and later
Windows MobileWindows Mobile Version 5.0 and later

Community Additions

© 2015 Microsoft