다음을 통해 공유


UnalignedStringCbLength function

Determines whether a string exceeds the specified length, in bytes.

The function is similar to StringCbLength, but it accepts an unaligned string pointer.

Syntax

HRESULT UnalignedStringCbLength(
  _In_      LPCTSTR psz,
  _In_      size_t  cbMax,
  _Out_opt_ size_t  *pcbLength
);

Parameters

  • psz [in]
    The string whose length is to be checked.

  • cbMax [in]
    The maximum number of bytes allowed in psz, including those used for the terminating null character. This value cannot exceed STRSAFE_MAX_CCH * sizeof(TCHAR).

  • pcbLength [out, optional]
    The number of bytes in psz, excluding those used for the terminating null character. This value is valid only if pcb is not NULL and the function succeeds.

Return value

This function can return one of the following values. It is strongly recommended that you use the SUCCEEDED and FAILED macros to test the return value of this function.

Return code Description
S_OK

The string at psz was not NULL, and the length of the string (including the terminating null character) is less than or equal to cbMax characters.

STRSAFE_E_INVALID_PARAMETER

The value in psz is NULL, cbMax is larger than STRSAFE_MAX_CCH * sizeof(TCHAR), or psz is longer than cbMax.

 

Requirements

Minimum supported client

Windows Vista [desktop apps | UWP apps]

Minimum supported server

Windows Server 2008 [desktop apps | UWP apps]

Header

StrSafe.h

Unicode and ANSI names

UnalignedStringCbLengthW (Unicode) and StringCbLengthA (ANSI)