Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

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.


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


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 codeDescription

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.


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



Minimum supported client

Windows Vista [desktop apps | UWP apps]

Minimum supported server

Windows Server 2008 [desktop apps | UWP apps]



Unicode and ANSI names

UnalignedStringCchLengthW (Unicode) and StringCchLengthA (ANSI)



© 2018 Microsoft