网站首页  词典首页

请输入您要查询的函数:

 

术语 stringcbgetsex
释义 StringCbGetsEx
语法:
HRESULT StringCbGetsEx( LPTSTR pszDest,
size_t cbDest,
LPTSTR *ppszDestEnd,
size_t *pcbRemaining,
DWORD dwFlags
);
StringCbGetsEx功能
StringCbGetsEx是更换获得。大小,以字节为目标缓冲区提供的功能,以确保不会写入StringCbGetsEx过去这个缓冲区的末尾。它从标准输入,一个新行一行文本('\\ ?')结束输入。该行文本复制到目标缓冲区和回车与空字符替换。
StringCbGetsEx增加了StringCbGets功能通过返回一个指向目标字符串的结束以及闲置字节数在该字符串。旗也可以传递给函数的额外控制。
注意:此功能只能用于内部。
参数
pszDest
[out]指向的缓冲区接收输入。
cbDest
[in]的目标缓冲区的大小,以字节为单位。此值必须大于sizeof(TCHAR的功能),以取得成功。所允许的最大字节数为STRSAFE_MAX_CCH * sizeof(TCHAR)。如果cbDest太小举行文本完全一致,数据被截断。
ppszDestEnd
[内]的指针地址的pszDest结束。如果ppszDestEnd不为NULL和任何数据到目标缓冲区复制的,在该字符串的结束点,终止空字符。
pcbRemaining
[out]指向一个变量,表示未使用的字节pszDest,包括终止空字符使用的数量。如果pcbRemaining为NULL,则计数不保留或退回。
dwFlags
[in]一个或多个下列值。
STRSAFE_FILL_BEHIND_NULL
如果函数成功,在dwFlags(0)低字节是用来填补pszDest以下终止空字符初始化部分。
STRSAFE_IGNORE_NULLS
对待像(空字符串文字("")).空字符串指针此标志可用于模拟如lstrcpy职能。
STRSAFE_FILL_ON_FAILURE
如果函数失败,在dwFlags(0)低字节是用来填充整个pszDest缓冲区,缓冲区空终止。在一个STRSAFE_E_INSUFFICIENT_BUFFER故障的情况下,任何截断的字符串返回的覆盖。
STRSAFE_NULL_ON_FAILURE
如果函数失败,pszDest设置为空字符串(文字("")).在一个STRSAFE_E_INSUFFICIENT_BUFFER故障的情况下,任何截断字符串覆盖。
STRSAFE_NO_TRUNCATION
正如STRSAFE_NULL_ON_FAILURE情况下,如果函数失败,pszDest设置为空字符串(文字("")).在一个STRSAFE_E_INSUFFICIENT_BUFFER故障的情况下,任何截断字符串覆盖。
返回值
请注意,此函数返回的hresult而不是得到,它返回一个指针。我们强烈建议您使用的成功和失败宏来测试这个函数的返回值。
S_OKData是从stdin读取,复制到在pszDest缓冲区,缓冲区是空终止。
STRSAFE_E_END_OF_FILEIndicates错误或最终文件的情况。使用feof或ferror,以确定哪一个已经发生。
STRSAFE_E_INVALID_PARAMETERThe在cbDest值大于最大允许值或无效标志获得通过。
STRSAFE_E_INSUFFICIENT_BUFFERThe在cbDest值为1或更少。
备注
StringCbGetsEx提供了代码中的适当缓冲处理额外的处理。可怜的缓冲处理是牵连,许多安全问题涉及缓冲区溢出。 StringCbGetsEx总是空终止一个非零长度目标缓冲区。
StringCbGetsEx可以用在它的通用形式,或作为StringCbGetsExA特别(为ANSI字符串)或StringCbGetsExW(为Unicode字符串)。该表格使用取决于您的数据。
字符串数据String类型LiteralFunction
字符“字符串”StringCbGetsExA
TCHARTEXT(“字符串”)StringCbGetsEx
WCHARL“字符串”StringCbGetsExW
StringCbGetsEx及其ANSI和Unicode的变种替换这些功能:
得到
_getws
_getts
StringCbGetsEx并非fgets更换。该函数不替换终止空字符换行符。
在pszDest价值不应是NULL,除非STRSAFE_IGNORE_NULLS标志被指定。然而,由于一个错误没有足够的空间仍可能会返回空值,即使被忽略。
功能信息
Headerstrsafe.h
import libraryNone
参见
StringCchGetsEx,StringCbGets
==英文原文==StringCbGetsEx Function
StringCbGetsEx is a replacement for gets . The size, in bytes, of the destination buffer is provided to the function to ensure that StringCbGetsEx 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.
StringCbGetsEx adds to the functionality of StringCbGets by returning a pointer to the end of the destination string as well as the number of bytes left unused in that string. Flags may also be passed to the function for additional control.
Note This function can only be used inline.
Syntax
HRESULT StringCbGetsEx( LPTSTR pszDest,
size_t cbDest,
LPTSTR *ppszDestEnd,
size_t *pcbRemaining,
DWORD dwFlags
);
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.
ppszDestEnd
[out] Address of a pointer to the end of pszDest. If ppszDestEnd is non-NULL and any data is copied into the destination buffer, this points to the terminating null character at the end of the string.
pcbRemaining
[out] Pointer to a variable that indicates the number of unused bytes in pszDest, including those used for the terminating null character. If pcbRemaining is NULL, the count is not kept or returned.
dwFlags
[in] One or more of the following values.
STRSAFE_FILL_BEHIND_NULL
If the function succeeds, the low byte of dwFlags (0) is used to fill the uninitialized portion of pszDest following the terminating null character.
STRSAFE_IGNORE_NULLS
Treat null string pointers like empty strings (TEXT("")). This flag is useful for emulating functions such as lstrcpy .
STRSAFE_FILL_ON_FAILURE
If the function fails, the low byte of dwFlags (0) is used to fill the entire pszDest buffer, and the buffer is null-terminated. In the case of a STRSAFE_E_INSUFFICIENT_BUFFER failure, any truncated string returned is overwritten.
STRSAFE_NULL_ON_FAILURE
If the function fails, pszDest is set to an empty string (TEXT("")). In the case of a STRSAFE_E_INSUFFICIENT_BUFFER failure, any truncated string is overwritten.
STRSAFE_NO_TRUNCATION
As in the case of STRSAFE_NULL_ON_FAILURE, if the function fails, pszDest is set to an empty string (TEXT("")). In the case of a STRSAFE_E_INSUFFICIENT_BUFFER failure, any truncated string is overwritten.
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 or an invalid flag was passed.
STRSAFE_E_INSUFFICIENT_BUFFERThe value in cbDest is 1 or less.
Remarks
StringCbGetsEx provides additional processing for proper buffer handling in your code. Poor buffer handling is implicated in many security issues that involve buffer overruns. StringCbGetsEx always null-terminates a non-zero-length destination buffer.
StringCbGetsEx can be used in its generic form, or specifically as StringCbGetsExA (for ANSI strings) or StringCbGetsExW (for Unicode strings). The form to use is determined by your data.
String Data TypeString LiteralFunction
char"string"StringCbGetsExA
TCHARTEXT("string")StringCbGetsEx
WCHARL"string"StringCbGetsExW
StringCbGetsEx and its ANSI and Unicode variants are replacements for these functions:
gets
_getws
_getts
StringCbGetsEx 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 unless the STRSAFE_IGNORE_NULLS flag is specified. However, an error due to insufficient space may still be returned even though null values are ignored.
Function Information
Headerstrsafe.h
Import libraryNone
See Also
StringCchGetsEx , StringCbGets
==原始网址==http://msdn.microsoft.com/en-us/library/ms647507(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:26:10