SysAllocStringByteLen

Windows Mobile 6.5
A version of this page is also available for
4/8/2010

This function takes an ANSI string as input, and returns an allocated string. This function does not perform ANSI to Unicode translation. It is valid only for 32-bit systems.


BSTR SysAllocStringByteLen(
  char FAR* psz, 
  unsigned int len 
);

psz

[in] Null-terminated string to copy, or NULL to keep the string uninitialized.

len

[in] Number of bytes to copy from psz. A null character is placed afterwards, allocating a total of len+1 bytes.

Returns the allocated string to indicate success, or NULL to indicate that insufficient memory exists.

This function is provided to create strings that contain binary data. You can use this type of string only in situations where it will not be translated from ANSI to Unicode, or vice versa.

For example, do not use these strings between a 16-bit application and a 32-bit application running on a 32-bit Windows system. The OLE 16-bit to 32-bit (and 32-bit to 16-bit) interoperability layer translates the string and corrupts the binary data.

The preferred method of passing binary data is to use a SAFEARRAY of VT_UI1, which is not translated by OLE.

If psz is NULL, a string of the requested length is allocated, but not initialized.

The string designated by psz can contain embedded null characters, and does not need to end with a NULL.

Free the returned string later with SysFreeString.

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

Headeroleauto.h
Libraryoleaut32.lib
Windows Embedded CEWindows CE 2.0 and later
Windows MobileWindows Mobile Version 5.0 and later

Community Additions

Show: