SysStringLen

UINT SysStringLen( 
  BSTR  bstr  
);
 

Returns the length of a BSTR.

Parameter

bstr
A BSTR allocated previously. Cannot be Null.

Return Value

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

Comments

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, this function always returns the number of characters specified in the cch parameter at allocation time.

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));

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.