gpt4 book ai didi

c++ - C++ 中的 PeekMessage 函数和命名管道

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:05:57 24 4
gpt4 key购买 nike

关于:

PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)

If hWnd is NULL, PeekMessage retrieves messages for any window that belongs to the current thread, and any messages on the current thread's message queue whose hwnd value is NULL (see the MSG structure). Therefore if hWnd is NULL, both window messages and thread messages are processed.

通过命名管道接收的消息是否包含在窗口消息线程消息中?

最佳答案

绝对不是。命名管道不发送窗口消息。

此上下文中的线程消息比较特殊,与命名管道无关。

使用MsgWaitForMultipleObjects相反。

代码示例:

void MessageLoop(HANDLE hNamedPipe)
{
do {
DWORD res = MsgWaitForMultipleObjects(1, &hNamedPipe, INFINITE, QS_ALLEVENTS, MWMO_INPUTAVAILABLE);
if (res == WAIT_OBJECT_0) {
/* Handle named pipe -- at this point ReadFile will not block */
} else if (res == WAIT_OBJECT_0 + 1) {
MSG msg;
if (!GetMessage(&msg, NULL, 0, 0))
break; /* WM_QUIT */
TranslateMessage(&msg);
DispatchMessage(&msg);
}
} while (1);
}

关于c++ - C++ 中的 PeekMessage 函数和命名管道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3544491/

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