网站首页  词典首页

请输入您要查询的函数:

 

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

[in]指向包含缓冲区的长度正在检查字符串。
cbMax
[in]对氧化锆允许字节,包括终止空字符使用的最大数量。此值不能超过STRSAFE_MAX_CCH * sizeof(TCHAR)。
电路板
[out]指向类型包含在锆的字节数,不包括终止空字符使用的size_t变量。此值才有效,如果不为null,电路板和函数成功。
返回值
请注意,此函数返回,而不是strlen,它返回一个整数的hresult。我们强烈建议您使用的成功和失败宏来测试这个函数的返回值。
S_OKThe在锆字符串不为null,以及字符串的长度(包括终止空字符)小于或等于cbMax字符。
STRSAFE_E_INVALID_PARAMETERThe在锆值为NULL,cbMax大于STRSAFE_MAX_CCH * sizeof(TCHAR),或氧化锆的长度超过cbMax。
备注
StringCbLength是一个在您的代码正确处理额外的缓冲工具。可怜的缓冲处理是牵连,许多安全问题涉及缓冲区溢出。
StringCbLength可以用在它的通用形式,或作为StringCbLengthA特别(为ANSI字符串)或StringCbLengthW(为Unicode字符串)。该表格使用取决于您的数据。
字符串数据String类型LiteralFunction
字符“字符串”StringCbLengthA
TCHARTEXT(“字符串”)StringCbLength
WCHARL“字符串”StringCbLengthW
功能信息
Headerstrsafe.h
import librarystrsafe.lib
参见
StringCchLength
==英文原文==StringCbLength Function
StringCbLength is a replacement for strlen . It is used to ensure that a string is not larger than a given length, in bytes. If that condition is met, StringCbLength returns the current length of the string in bytes, not including those used for the terminating null character.
Syntax
HRESULT StringCbLength( LPCTSTR psz,
size_t cbMax,
size_t *pcb
);
Parameters
psz
[in] Pointer to a buffer containing the string whose length is being 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).
pcb
[out] Pointer to a variable of type size_t containing 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
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 cbMax characters.
STRSAFE_E_INVALID_PARAMETERThe value in psz is NULL, cbMax is larger than STRSAFE_MAX_CCH * sizeof(TCHAR), or psz is longer than cbMax.
Remarks
StringCbLength is an additional tool for proper buffer handling in your code. Poor buffer handling is implicated in many security issues that involve buffer overruns.
StringCbLength can be used in its generic form, or specifically as StringCbLengthA (for ANSI strings) or StringCbLengthW (for Unicode strings). The form to use is determined by your data.
String Data TypeString LiteralFunction
char"string"StringCbLengthA
TCHARTEXT("string")StringCbLength
WCHARL"string"StringCbLengthW
Function Information
Headerstrsafe.h
Import librarystrsafe.lib
See Also
StringCchLength
==原始网址==http://msdn.microsoft.com/en-us/library/ms647509(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:16:18