SysAllocStringLen

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

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

Note: This function does NOT convert a char * string into a unicode BSTR. The BSTR returned with this function can only be used with 16 bit applications.

Parameters

pch
A pointer to cch characters to copy, or Null to keep the string uninitialized.
cch
Number of characters to copy from pch. A null character is placed afterwards, allocating a total of cch+1 characters.

Return Value

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

Comments

If pch is Null, a string of the requested length is allocated, but not initialized. The pch string can contain embedded null characters and does not need to end with a Null. Free the returned string later with SysFreeString.

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.