这个函数虽然返回值类型是BOOL,但是还有可能返回-1 !
Return Value
BOOL
If the function retrieves a message other than WM_QUIT , the return value is nonzero.
If the function retrieves the WM_QUIT message, the return value is zero.
If there is an error, the return value is -1. For example, the function fails if hWnd is an invalid window handle or lpMsg is an invalid pointer. To get extended error information, call GetLastError .
Because the return value can be nonzero, zero, or -1, avoid code like this:
The possibility of a -1 return value means that such code can lead to fatal application errors. Instead, use code like this:
本文解析了GetMessage函数的返回值特点及其正确处理方式,强调了返回值为-1时可能出现的应用错误,并提供了一段示例代码来展示如何避免此类问题。

960

被折叠的 条评论
为什么被折叠?



