1、个人感觉:

  1.1、MSDN中(https://msdn.microsoft.com/en-us/library/ms684242.aspx),说:

dwWakeMask [in]

  The input types for which an input event object handle will be added to the array of object handles.

    ZC: 也就是说,会在 "event object handle"数组的最后 加入一个 事件对象句柄,这个 事件对象句柄 专门用于响应消息的。这里 我将它称为 "消息事件对象句柄"(它对应的对象就称为"消息事件对象")

  1.1、MSDN中(https://msdn.microsoft.com/en-us/library/ms684242.aspx),说:

The QS_ALLPOSTMESSAGE and QS_POSTMESSAGE flags differ in when they are cleared. QS_POSTMESSAGE is cleared when you call GetMessage or PeekMessage, whether or not you are filtering messages. QS_ALLPOSTMESSAGE is cleared when you call GetMessage or PeekMessage without filtering messages (wMsgFilterMin and wMsgFilterMax are 0). This can be useful when you call PeekMessage multiple times to get messages in different ranges.

    文中多次提到 "cleared",这里指  "消息事件对象"的状态。

    ZC: 我做的测试结果:

      QS_ALLPOSTMESSAGE : 只要消息不取走,"消息事件对象"就一直是 有信号的状态(不管是否过滤消息(GetMessage和PeekMessage函数的wMsgFilterMin和wMsgFilterMax参数))。消息被取走后,"消息事件对象" 才会变成 无信号状态。

      QS_POSTMESSAGE:就算消息不取走,"消息事件对象" 还是会被设置成 无信号状态。未取走的消息还保留在消息队列中。

2、

3、Delphi

  3.1、界面:

  3.2、代码:

procedure TfrmMain.btnPost1000Click(Sender: TObject);
var hWnd1 :HWND;
begin
hWnd1 := StrToInt('$'+Trim(edtHWnd.Text));
PostMessage(hWnd1, WM_USER+, , );
end; procedure TfrmMain.btnPost1001Click(Sender: TObject);
var hWnd1 :HWND;
begin
hWnd1 := StrToInt('$'+Trim(edtHWnd.Text));
PostMessage(hWnd1, WM_USER+, , );
end; procedure TfrmMain.btnSend1001Click(Sender: TObject);
var hWnd1 :HWND;
begin
hWnd1 := StrToInt('$'+Trim(edtHWnd.Text));
SendMessage(hWnd1, WM_USER+, , );
end; procedure TfrmMain.btnPostCloseClick(Sender: TObject);
var hWnd1 :HWND;
begin
hWnd1 := StrToInt('$'+Trim(edtHWnd.Text));
SendMessage(hWnd1, WM_CLOSE, , );
end; procedure TfrmMain.btnSetEventClick(Sender: TObject);
var hEvent :Cardinal;
iErr :integer;
begin
hEvent := OpenEvent(EVENT_ALL_ACCESS, false, '__VC_MsgWaitForMultipleObjects_TEST_20180105__');
iErr := GetLastError;
Memo1.Lines.Add('OpenEvent return : '+IntToStr(hEvent)+', GetLastError : '+inttostr(iErr)); SetEvent(hEvent); CloseHandle(hEvent);
end; procedure TfrmMain.btnPost1100Click(Sender: TObject);
var hWnd1 :HWND;
begin
hWnd1 := StrToInt('$'+Trim(edtHWnd.Text));
PostMessage(hWnd1, WM_USER+, , );
end; procedure TfrmMain.btnSend1100Click(Sender: TObject);
var hWnd1 :HWND;
begin
hWnd1 := StrToInt('$'+Trim(edtHWnd.Text));
SendMessage(hWnd1, WM_USER+, , );
end;

4、VC6 测试代码:

#include <windows.h>

#include <io.h>
#include <fcntl.h>
#include <stdio.h> HINSTANCE g_hInstance = ;
HWND g_hWnd = ; LRESULT CALLBACK ProcWindow(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); void InitConsoleWindow()
{
AllocConsole();
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
int hCrt = _open_osfhandle((long)handle,_O_TEXT);
FILE * hf = _fdopen( hCrt, "w" );
*stdout = *hf;
} //////////// //////////// //////////// //////////// //////////// //////////// int WINAPI WinMain(
HINSTANCE _hInstance, // 当前 hInstance句柄
HINSTANCE _hPrevInstance, // 之前的 hInstance句柄
LPSTR _lpCmdLine, // 命令行
int _nCmdShow // 显示状态
)
{
g_hInstance = _hInstance; // 程序(.exe)的图标貌似默认是 资源文件中 的第一个图标??
WNDCLASS wndcls = {};
wndcls.style = CS_HREDRAW | CS_VREDRAW;
wndcls.lpfnWndProc = ProcWindow;
wndcls.cbClsExtra = ;
wndcls.cbWndExtra = ;
wndcls.hInstance = _hInstance;
wndcls.hIcon = LoadIcon(NULL, IDI_ERROR); // 窗口图标
wndcls.hCursor = LoadCursor(NULL, IDC_CROSS);
wndcls.hbrBackground= (HBRUSH)GetStockObject(WHITE_BRUSH); // 背景画刷
wndcls.lpszMenuName = NULL;
wndcls.lpszClassName= "zc20110929";
// 注册窗口类
RegisterClass(&wndcls); g_hWnd = CreateWindowEx(
NULL, //WS_EX_CLIENTEDGE,
wndcls.lpszClassName,
"ZC Window",
WS_OVERLAPPEDWINDOW,
, ,
, ,
NULL,
NULL, //g_hMenu,
_hInstance,
NULL); ShowWindow(g_hWnd, SW_SHOWNORMAL);
UpdateWindow(g_hWnd); MSG msg;
while(GetMessage(&msg, , , ))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
} return msg.wParam;
} HANDLE g_hEvent = NULL;
//#define PM_QS_POSTMESSAGE ((QS_POSTMESSAGE | QS_HOTKEY | QS_TIMER) << 16)
#define PM_QS_POSTMESSAGE ((QS_POSTMESSAGE) << 16) int g_iInc = ; LRESULT CALLBACK ProcWindow(
HWND _hWnd, // 窗口句柄
UINT _uMsg, // 消息ID(identifier)
WPARAM _wParam,
LPARAM _lParam)
{
switch (_uMsg)
{
case WM_USER+:
{
printf("Before MsgWaitForMultipleObjects .\n");
//DWORD dwRtn = MsgWaitForMultipleObjects(1, &g_hEvent, false, INFINITE, QS_SENDMESSAGE);
while ()
{
DWORD dwRtn = MsgWaitForMultipleObjects(, &g_hEvent, false, INFINITE, QS_SENDMESSAGE | QS_POSTMESSAGE);
if (dwRtn == )
break;
printf("MsgWaitForMultipleObjects return %d\n", dwRtn);
/*MSG msg;
::GetMessage(&msg, _hWnd, 2024, 2026);
printf("GetMessage get message : %d\n", msg.message);*/
MSG msg;
//dwRtn = ::PeekMessage(&msg, _hWnd, 2024, 2026, PM_REMOVE | PM_QS_POSTMESSAGE);// PM_QS_POSTMESSAGE
//dwRtn = ::PeekMessage(&msg, _hWnd, 2024, 2026, PM_QS_POSTMESSAGE);// PM_QS_POSTMESSAGE
//printf("PeekMessage get message(1) : %d, %d\n", msg.message, dwRtn);
dwRtn = ::PeekMessage(&msg, _hWnd, , , PM_NOREMOVE | PM_QS_POSTMESSAGE);
printf("PeekMessage get message(2) : %d, %d\n", msg.message, dwRtn);
if (msg.message == WM_CLOSE)
break; if (g_iInc == )
{
::GetMessage(&msg, _hWnd, , );
printf("GetMessage get message : %d\n", msg.message);
}
g_iInc ++;
printf("\t ==> %d\n", g_iInc);
if (g_iInc >= )
{//*
// system("pause");
::GetMessage(&msg, _hWnd, , );
printf("GetMessage get message : %d\n", msg.message);
// ::MessageBox(0, "Text", "caption", 0);
//*/
break;
}
}
/* DWORD WINAPI MsgWaitForMultipleObjects(
_In_ DWORD nCount,
_In_ const HANDLE *pHandles,
_In_ BOOL bWaitAll,
_In_ DWORD dwMilliseconds,
_In_ DWORD dwWakeMask
);*/
printf("After MsgWaitForMultipleObjects .\n");
return ;
}
case WM_USER+:
{
printf("WM_USER+1001\n");
return ;
}
case WM_USER+:
{
printf("WM_USER+1100\n");
return ;
}
case WM_CREATE:
{
InitConsoleWindow();
printf("WM_CREATE\n");
g_hEvent = ::CreateEvent(NULL, false, false, "__VC_MsgWaitForMultipleObjects_TEST_20180105__");
printf("HWND : %d , 0x%X\n", _hWnd, _hWnd);
return ;
}
case WM_PAINT:
{
char buf[] = {};
sprintf(buf, "HWND : %d , 0x%08X", _hWnd, _hWnd); HDC hDc;
PAINTSTRUCT ps;
hDc = BeginPaint(_hWnd, &ps);
TextOut(hDc, , , buf, strlen(buf));
EndPaint(_hWnd, &ps);
return ;
// break;
}
case WM_CLOSE:
case WM_DESTROY:
{
DestroyWindow(_hWnd);
PostQuitMessage();
return ;
}
}
return DefWindowProc(_hWnd, _uMsg, _wParam, _lParam);
}

5、

MsgWaitForMultipleObjects_测试的更多相关文章

  1. SignalR系列续集[系列8:SignalR的性能监测与服务器的负载测试]

    目录 SignalR系列目录 前言 也是好久没写博客了,近期确实很忙,嗯..几个项目..头要炸..今天忙里偷闲.继续我们的小系列.. 先谢谢大家的支持.. 我们来聊聊SignalR的性能监测与服务器的 ...

  2. Apache Ignite之集群应用测试

    集群发现机制 在Ignite中的集群号称是无中心的,而且支持命令行启动和嵌入应用启动,所以按理说很简单.而且集群有自动发现机制感觉对于懒人开发来说太好了,抱着试一试的心态测试一下吧. 在Apache ...

  3. 测试一下StringBuffer和StringBuilder及字面常量拼接三种字符串的效率

    之前一篇里写过字符串常用类的三种方式<java中的字符串相关知识整理>,只不过这个只是分析并不知道他们之间会有多大的区别,或者所谓的StringBuffer能提升多少拼接效率呢?为此写个简 ...

  4. TechEmpower 13轮测试中的ASP.NET Core性能测试

    应用性能直接影响到托管服务的成本,因此公司在开发应用时需要格外注意应用所使用的Web框架,初创公司尤其如此.此外,糟糕的应用性能也会影响到用户体验,甚至会因此受到相关搜索引擎的降级处罚.在选择框架时, ...

  5. .NET Core系列 :4 测试

    2016.6.27 微软已经正式发布了.NET Core 1.0 RTM,但是工具链还是预览版,同样的大量的开源测试库也都是至少发布了Alpha测试版支持.NET Core, 这篇文章 The Sta ...

  6. 渗透测试工具BurpSuite做网站的安全测试(基础版)

    渗透测试工具BurpSuite做网站的安全测试(基础版) 版权声明:本文为博主原创文章,未经博主允许不得转载. 学习网址: https://t0data.gitbooks.io/burpsuite/c ...

  7. 在ubuntu16.10 PHP测试连接MySQL中出现Call to undefined function: mysql_connect()

    1.问题: 测试php7.0 链接mysql数据库的时候发生错误: Fatal error: Uncaught Error: Call to undefined function mysqli_con ...

  8. 【初学python】使用python调用monkey测试

    目前公司主要开发安卓平台的APP,平时测试经常需要使用monkey测试,所以尝试了下用python调用monkey,代码如下: import os apk = {'j': 'com.***.test1 ...

  9. CoreCRM 开发实录——Travis-CI 实现 .NET Core 程度在 macOS 上的构建和测试 [无水干货]

    上一篇文章我提到:为了使用"国货",我把 Linux 上的构建和测试委托给了 DaoCloud,而 Travis-CI 不能放着不用啊.还好,这货支持 macOS 系统.所以就把 ...

随机推荐

  1. MyEclipse与Eclipse配置清单

    MyEclipse与Eclipse配置清单 1.编码设置    workspace -> 设置全局编码utf-8    修改JSP编码(Encoding)为UTF-82.Java配置    格式 ...

  2. Harmonic Value Description HDU - 5916

    The harmonic value of the permutation p1,p2,⋯pn is ∑i=1n−1gcd(pi.pi+1) Mr. Frog is wondering about t ...

  3. 再论sklearn分类器

    https://www.cnblogs.com/hhh5460/p/5132203.html 这几天在看 sklearn 的文档,发现他的分类器有很多,这里做一些简略的记录. 大致可以将这些分类器分成 ...

  4. P2590 [ZJOI2008]树的统计(树链剖分)

    P2590 [ZJOI2008]树的统计 虽然是入门树剖模板 但是我终于1A了(大哭) 懒得写啥了(逃 #include<iostream> #include<cstdio> ...

  5. The POM for XXX is invalid, transitive dependencies (if any) will not be available解决方案

    今天,某个开发的环境在编译的时候提示警告The POM for XXX is invalid, transitive dependencies (if any) will not be availab ...

  6. rabbitmq heartbeat missing with heartbeat = N seconds原因总结

    一直以来,在我们大规模使用rabbitmq的服务端应用中,都没有出现rabbitmq心跳超时而造成的的影响,反倒是在rabbitmq-cpp客户端出现过很多次该问题,一直以为客户端lib实现的问题(不 ...

  7. 八数码问题 Eight Digital Problem

    八数码问题 利用启发式搜索,找出以下问题的最优解. #include <iostream> #include <vector> #include <algorithm&g ...

  8. 利用shell脚本通过ssh绕过输入密码直接登录主机

    shell #!/usr/bin/expect spawn ssh root@192.168.137.141 expect "*password:" send "lizh ...

  9. [c/c++] programming之路(8)、汇编、求模、自增自减

    一.插入汇编 #include<stdio.h> void main(){ ; num=num+; //插入汇编语言 _asm{ mov eax,num;//eax是一个存储器,将num的 ...

  10. topcoder srm 370 div1

    problem1 link 枚举每一种大于等于$n$的计算其概率即可. problem2 link 首先二分答案,然后计算.令$f[i][j]$表示移动完前$i$最后一个在位置$j$的最小代价. pr ...