网站首页  词典首页

请输入您要查询的函数:

 

术语 stringcbgets
释义 StringCbGets
语法:
HRESULT StringCbGets( LPTSTR pszDest,
size_t cbDest
);
StringCbGets功能
StringCbGets是更换获得。大小,以字节为目标缓冲区提供的功能,以确保不会写入StringCbGets过去这个缓冲区的末尾。它从标准输入,一个新行一行文本('\\ ?')结束输入。该行文本复制到目标缓冲区和回车与空字符替换。
注意:此功能只能用于内部。
参数
pszDest
[out]指向的缓冲区接收输入。
cbDest
[in]的目标缓冲区的大小,以字节为单位。此值必须大于sizeof(TCHAR的功能),以取得成功。所允许的最大字节数为STRSAFE_MAX_CCH * sizeof(TCHAR)。如果cbDest太小举行文本完全一致,数据被截断。
返回值
请注意,此函数返回的hresult而不是得到,它返回一个指针。我们强烈建议您使用的成功和失败宏来测试这个函数的返回值。
S_OKData是从stdin读取,复制到在pszDest缓冲区,缓冲区是空终止。
STRSAFE_E_END_OF_FILEIndicates错误或最终文件的情况。使用feof或ferror,以确定哪一个已经发生。
STRSAFE_E_INVALID_PARAMETERThe在cbDest值大于允许的最大值。
STRSAFE_E_INSUFFICIENT_BUFFERThe在cbDest值为sizeof(TCHAR)或更少。
备注
StringCbGets提供了代码中的适当缓冲处理额外的处理。可怜的缓冲处理是牵连,许多安全问题涉及缓冲区溢出。 StringCbGets总是空终止一个非零长度目标缓冲区。
StringCbGets可以用在它的通用形式,或作为StringCbGetsA特别(为ANSI字符串)或StringCbGetsW(为Unicode字符串)。该表格使用取决于您的数据。
字符串数据String类型LiteralFunction
字符“字符串”StringCbGetsA
TCHARTEXT(“字符串”)StringCbGets
WCHARL“字符串”StringCbGetsW
StringCbGets及其ANSI和Unicode的变种替换这些功能:
得到
_getws
_getts
StringCbGets并非fgets更换。该函数不替换终止空字符换行符。
在pszDest价值不应是NULL。见StringCbGetsEx如果您需要的空字符串指针值的处理。
功能信息
Headerstrsafe.h
import libraryNone
参见
StringCchGets,StringCbGetsEx
==英文原文==StringCbGets Function
StringCbGets is a replacement for gets . The size, in bytes, of the destination buffer is provided to the function to ensure that StringCbGets does not write past the end of this buffer. It retrieves one line of text from stdin, a newline ('\\n') ending the input. The line of text is copied to the destination buffer, and the carriage return is replaced with a null character.
Note This function can only be used inline.
Syntax
HRESULT StringCbGets( LPTSTR pszDest,
size_t cbDest
);
Parameters
pszDest
[out] Pointer to a buffer which receives the input.
cbDest
[in] Size of the destination buffer, in bytes. This value must be greater than sizeof(TCHAR) for the function to succeed. The maximum number of bytes allowed is STRSAFE_MAX_CCH * sizeof(TCHAR). If cbDest is too small to hold the full line of text, the data is truncated.
Return Value
Note that this function returns an HRESULT as opposed to gets, which returns a pointer. It is strongly recommended that you use the SUCCEEDED and FAILED macros to test the return value of this function.
S_OKData was read from stdin, was copied to the buffer at pszDest, and the buffer was null-terminated.
STRSAFE_E_END_OF_FILEIndicates an error or end-of-file condition. Use feof or ferror to determine which one has occurred.
STRSAFE_E_INVALID_PARAMETERThe value in cbDest is larger than the maximum allowed value.
STRSAFE_E_INSUFFICIENT_BUFFERThe value in cbDest is sizeof(TCHAR) or less.
Remarks
StringCbGets provides additional processing for proper buffer handling in your code. Poor buffer handling is implicated in many security issues that involve buffer overruns. StringCbGets always null-terminates a non-zero-length destination buffer.
StringCbGets can be used in its generic form, or specifically as StringCbGetsA (for ANSI strings) or StringCbGetsW (for Unicode strings). The form to use is determined by your data.
String Data TypeString LiteralFunction
char"string"StringCbGetsA
TCHARTEXT("string")StringCbGets
WCHARL"string"StringCbGetsW
StringCbGets and its ANSI and Unicode variants are replacements for these functions:
gets
_getws
_getts
StringCbGets is not a replacement for fgets . That function does not replace newline characters with a terminating null character.
The value of pszDest should not be NULL. See StringCbGetsEx if you require the handling of null string pointer values.
Function Information
Headerstrsafe.h
Import libraryNone
See Also
StringCchGets , StringCbGetsEx
==原始网址==http://msdn.microsoft.com/en-us/library/ms647505(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:15:37