StringCchLength
判断字符串是否在字符数量上超出指定的长度的函数
StringCchLength,是判断字符串是否在字符数量上超出指定的长度的函数
StringCchLength Function
Determines whether a string exceeds the specified length, in characters.
StringCchLength is a replacement for the following functions:
StringCchLength 是下面函数的替代
strlen, wcslen, _tcslen
Syntax语法
HRESULT StringCchLength( __in LPCTSTR psz, __in size_t cchMax, __out size_t *pcch);
Parameters参数
psz [in] LPCTSTRThe string whose length is to be checked.
指向被检查的字符串的指针.
cchMax [in] size_tThe maximum number of characters allowed in psz, including the terminating null character. This value cannot exceed STRSAFE_MAX_CCH.
psz里最大允许的字符数量,包括结尾的null字符,这个数量不能超过STRSAFE_MAX_CCH
pcch [out] size_tThe 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.
psz里的字符数量,不包括结尾的null字符,这个值只有在pcch指针不为null,且函数成功时有效
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.
这个函数可能返回下面这些值,强烈建议您使用SUCCEEDED和FAILED宏来测试这个函数的返回值.
Note that this function returns an HRESULT value, unlike the functions that it replaces.
请注意:这个函数返回的是一个HRESULT值,而不是它要替代的函数所返回的size_t
Remarks请注意
Compared to the functions it replaces, StringCchLength is an additional tool for proper buffer handling in your code. Poor buffer handling is implicated in many security issues that involve buffer overruns.
和这个函数所要代替的函数相比,StringCchLength是在您代码里,正确处理缓存区的一个附加功能,因为小缓冲处理会牵连很多安全问题,例如缓存区溢出
StringCchLength can be used in its generic form, or in its more specific forms. The data type of the string determines the form of this function that you should use.
StringCchLength可以以笼统的格式使用,或者特殊的格式,字符串里的字符类型决定您应该使用的函数类型
Requirements需求
See Also参见
StringCbLength
参考资料
最新修订时间:2022-04-04 09:43
目录
概述
参考资料