Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Yes of course, it possible. I faced a similar issue some months ago where some (unknown, but probably mine) app was preventing shutdown, so I wrote some quick code that used EnumWindows to enumerate all the top level windows, sent each one a WM_QUERYENDSESSION message, noted what the return value from SendMessage was and stopped the enumeration if anyone returned FALSE. Took about ten minutes in C++/MFC. This was the guts of it:</p> <pre><code>void CQes_testDlg::OnBtnTest() { // enumerate all the top-level windows. m_ctrl_ListMsgs.ResetContent(); EnumWindows (EnumProc, 0); } BOOL CALLBACK EnumProc (HWND hTarget, LPARAM lParam) { CString csTitle; CString csMsg; CWnd * pWnd = CWnd::FromHandle (hTarget); BOOL bRetVal = TRUE; DWORD dwPID; if (pWnd) { pWnd-&gt;GetWindowText (csTitle); if (csTitle.GetLength() == 0) { GetWindowThreadProcessId (hTarget, &amp;dwPID); csTitle.Format ("&lt;PID=%d&gt;", dwPID); } if (pWnd-&gt;SendMessage (WM_QUERYENDSESSION, 0, ENDSESSION_LOGOFF)) { csMsg.Format ("window 0x%X (%s) returned TRUE", hTarget, csTitle); } else { csMsg.Format ("window 0x%X (%s) returned FALSE", hTarget, csTitle); bRetVal = FALSE; } mg_pThis-&gt;m_ctrl_ListMsgs.AddString (csMsg); } else { csMsg.Format ("Unable to resolve HWND 0x%X to a CWnd", hTarget); mg_pThis-&gt;m_ctrl_ListMsgs.AddString (csMsg); } return bRetVal; } </code></pre> <p>mg_pThis was just a local copy of the dialog's this pointer, so the helper callback could access it. I told you it was quick and dirty :-)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload