Determine whether a window is suspended (is not responding), in the Multi-window programming is often used, before the other window to send messages, for the purpose of the window can be determined to receive the message, often before the first check whether the window is suspended, we used to use the following method:
[CPP]View PlainCopy
- // determine if a window has stopped responding (timeout 0.5 seconds)
- DWORD_PTR DWRESULT = 0;  
- lresult lr = ::sendmessagetimeout (g_hwin, wm_null, 0, 0, smto_abortifhung | smto_block, 500, &dwresult);
- if (LR)
- {  
- // can also respond
- }  
- else
- {  
- // has stopped responding (as the old saying window hangs dead)
- }  
Later on (http://blog.csdn.net/wingeek/article/details/3875903) saw a method using the Ishungappwindow API to directly determine whether the window is suspended, From the MSDN view (http://msdn.microsoft.com/en-us/library/ms633526.aspx), this API has been provided from Windows2000, but until Windowsxp_ The SDK was only available at the beginning of SP1 and windows2003. Start guessing is whether the internal is the use of sendmessagetimeout implementation, real-time tracking down, found not. Here is the implementation code for Ishungappwindow:
77d69c61 > 8BFF MOV edi,edi
77d69c63. EBP
77D69C64 8BEC MOV Ebp,esp
77D69C66 6A 4
77d69c68 FF75 PUSH DWORD PTR ss:[ebp+8]
77d69c6b E8 6BEAFAFF Call user32.77d186db
77d69c70 F7d8 NEG EAX
77D69C72 1bc0 SBB Eax,eax
77d69c74 F7d8 NEG EAX
77d69c76 5D POP EBP
77d69c77 C2 0400 RETN 4
77d186db B8 E3110000 MOV eax,11e3
77d186e0 BA 0003fe7f MOV edx,7ffe0300
77d186e5 FF12 call DWORD PTR Ds:[edx]; Ntdll. Kifastsystemcall
77d186e7 C2 0800 RETN 8
Inside the Ishungappwindow is actually very simple, Call user32.77d186db This function, this function is actually ntuserquerywindow (from the back can be seen inside the 77d186db directly to the kernel call, the function number eax is 11E3), where 7ffe0300 is both Kifastsystemcall land Address, in the place of the call Ntuserquerywindow, push the two parameters, namely Ntuserquerywindow (HWND, 4), the first parameter is the handle of the destination window, the second parameter is the query ID, that is, indicating what information to check this window, 4 is to check whether this window hangs, directly by the RING0 to achieve ...
http://blog.csdn.net/magictong/article/details/7296250
Determine if a window is suspended (send Wm_null message, or call Ishungappwindow API to test)