I wanted to know if any application in the foreground(except this application) is closed by clicking the cross button on the top-right or any other way like Ctrl + f4
.
Here is what I have created so far:
- create window event
void CALLBACK WinEventProc(
HWINEVENTHOOK hWinEventHook,
DWORD event,
HWND hwnd,
LONG idObject,
LONG idChild,
DWORD dwEventThread,
DWORD dwmsEventTime
) {
handleProcess(hwnd);
// handleProcess does other operations
}
- Call the window event in
wWinMain()
...
winDestructionHook = SetWinEventHook(EVENT_OBJECT_DESTROY, EVENT_OBJECT_DESTROY,
NULL, WinEventProc, 0, 0, WINEVENT_OUTOFCONTEXT);
...
The problem here is the window event is triggered without any window-closed action, but I wanted to activate it only on application closed.