次の方法で共有


UnalignedStringCchLength function

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

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

Syntax

HRESULT UnalignedStringCchLength(
  _In_      LPCTSTR psz,
  _In_      size_t  cchMax,
  _Out_opt_ size_t  *pcchLength
);

Parameters

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

  • cchMax [in]
    The maximum number of characters allowed in psz, including the terminating null character. This value cannot exceed STRSAFE_MAX_CCH.

  • pcchLength [out, optional]
    The number of characters in psz, not including the terminating null character. This value is valid only if pcch 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 cchMax characters.

STRSAFE_E_INVALID_PARAMETER

The value in psz is NULL, cchMax is larger than STRSAFE_MAX_CCH, or psz is longer than cchMax.

 

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

UnalignedStringCchLengthW (Unicode) and StringCchLengthA (ANSI)