gpt4 book ai didi

c - WIndows系统编程使用标准C库

转载 作者:太空宇宙 更新时间:2023-11-03 23:45:58 24 4
gpt4 key购买 nike

<分区>

我正在阅读 Johnson M. Hart Windows 系统编程。他有一个使用va_start 标准c 方法的方法。在下面的示例中,有人可以解释为什么将 Handle hOut 传递给 va_start 吗?

BOOL PrintStrings (HANDLE hOut, ...)

/* Write the messages to the output handle. Frequently hOut
will be standard out or error, but this is not required.
Use WriteConsole (to handle Unicode) first, as the
output will normally be the console. If that fails, use WriteFile.

hOut: Handle for output file.
... : Variable argument list containing TCHAR strings.
The list must be terminated with NULL. */
{
DWORD msgLen, count;
LPCTSTR pMsg;
va_list pMsgList; /* Current message string. */
va_start (pMsgList, hOut); /* Start processing msgs. */
while ((pMsg = va_arg (pMsgList, LPCTSTR)) != NULL) {
msgLen = lstrlen (pMsg);
if (!WriteConsole (hOut, pMsg, msgLen, &count, NULL)
&& !WriteFile (hOut, pMsg, msgLen * sizeof (TCHAR), &count, NULL)) {
va_end (pMsgList);
return FALSE;
}
}
va_end (pMsgList);
return TRUE;
}

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com