SysStringLen

This function returns the length of a BSTR.

At a Glance

Header file: Oleauto.h
Windows CE versions: 2.0 and later

Syntax

HRESULT SysStringLen(BSTR bstr);

Parameters

bstr

Unicode string that was allocated previously. It cannot be NULL.

Return Values

The number of characters in bstr, not including a terminating null character, indicates success.

Remarks

The returned value may be different from _fstrlen(bstr) if the BSTR was allocated with Sys[Re]AllocStringLen or SysAllocStringByteLen, and the passed-in characters included a null character in the first cch characters. For a BSTR allocated with Sys[Re]AllocStringLen or SysAllocStringByteLen, the SysStringLen function always returns the number of characters specified in the cch parameter at allocation time.

Windows CE supports only Unicode strings.

Passing into this function any invalid and, under some circumstances, NULL pointers will result in unexpected termination of the application.

Example

// Display the status message.
//
TextOut(
   hdc,
   rcMsg.left + (m_dxFont / 2),
   rcMsg.top + ((rcMsg.bottom - rcMsg.top - m_dyFont) / 2),
   m_BSTRMsg, SysStringLen(m_BSTRMsg));