网站首页  词典首页

请输入您要查询的函数:

 

术语 stringcchlength
释义 StringCchLength
语法:
HRESULT StringCchLength( LPCTSTR psz,
size_t cchMax,
size_t *pcch
);
StringCchLength功能
StringCchLength是一个strlen替换。它是用于确保一个字符串不大于给定长度的字符。如果条件得到满足,StringCchLength返回的字符串电流不包括终止空字符长度。
参数

[in]指向包含缓冲区的长度正在检查字符串。
cchMax
[in]对锆允许的最大字符数,包括终止空字符。此值不能超过STRSAFE_MAX_CCH。
环己烯
[out]指向类型包含在氧化锆中的字符数,不包括终止空字符size_t变量。此值才有效,如果不为null,环己烯和函数成功。
返回值
请注意,此函数返回,而不是strlen,它返回一个整数的hresult。我们强烈建议您使用的成功和失败宏来测试这个函数的返回值。
S_OKThe在锆字符串不为null,以及字符串的长度(包括终止空字符)小于或等于cchMax字符。
STRSAFE_E_INVALID_PARAMETERThe在锆值为NULL,cchMax大于STRSAFE_MAX_CCH,或氧化锆的长度超过cchMax。
备注
StringCchLength是一个在您的代码正确处理额外的缓冲工具。可怜的缓冲处理是牵连,许多安全问题涉及缓冲区溢出。
StringCchLength可以用在它的通用形式,或作为StringCchLengthA特别(为ANSI字符串)或StringCchLengthW(为Unicode字符串)。该表格使用取决于您的数据。
字符串数据String类型LiteralFunction
字符“字符串”StringCchLengthA
TCHARTEXT(“字符串”)StringCchLength
WCHARL“字符串”StringCchLengthW
功能信息
Headerstrsafe.h
import librarystrsafe.lib
参见
StringCbLength
==英文原文==StringCchLength Function
StringCchLength is a replacement for strlen . It is used to ensure that a string is not larger than a given length, in characters. If that condition is met, StringCchLength returns the current length of the string in characters, not including the terminating null character.
Syntax
HRESULT StringCchLength( LPCTSTR psz,
size_t cchMax,
size_t *pcch
);
Parameters
psz
[in] Pointer to a buffer containing the string whose length is being checked.
cchMax
[in] The maximum number of characters allowed in psz, including the terminating null character. This value cannot exceed STRSAFE_MAX_CCH.
pcch
[out] Pointer to a variable of type size_t containing the number of characters in psz, excluding the terminating null character. This value is valid only if pcch is not null and the function succeeds.
Return Value
Note that this function returns an HRESULT as opposed to strlen, which returns an integer. It is strongly recommended that you use the SUCCEEDED and FAILED macros to test the return value of this function.
S_OKThe 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_PARAMETERThe value in psz is NULL, cchMax is larger than STRSAFE_MAX_CCH, or psz is longer than cchMax.
Remarks
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 can be used in its generic form, or specifically as StringCchLengthA (for ANSI strings) or StringCchLengthW (for Unicode strings). The form to use is determined by your data.
String Data TypeString LiteralFunction
char"string"StringCchLengthA
TCHARTEXT("string")StringCchLength
WCHARL"string"StringCchLengthW
Function Information
Headerstrsafe.h
Import librarystrsafe.lib
See Also
StringCbLength
==原始网址==http://msdn.microsoft.com/en-us/library/ms647539(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 13:20:41