Skip to content

Commit 3ff30aa

Browse files
committed
Only post message to main window
1 parent 76ccaaa commit 3ff30aa

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Source/nsProcess.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ TCHAR szBuf[NSIS_MAX_STRLEN];
8989
/* Funtions prototypes and macros */
9090
int FIND_PROC_BY_NAME(TCHAR *szProcessName, BOOL bTerminate, BOOL bClose);
9191

92+
static BOOL IsMainWindow(HWND hWnd)
93+
{
94+
return GetWindow(hWnd, GW_OWNER) == (HWND)0 && IsWindowVisible(hWnd);
95+
}
96+
9297
/* NSIS functions code */
9398
void __declspec(dllexport) _FindProcess(HWND hwndParent, int string_size,
9499
TCHAR *variables, stack_t **stacktop, extra_parameters *extra)
@@ -139,16 +144,16 @@ BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
139144
return TRUE;
140145
}
141146

142-
BOOL CALLBACK EnumWindowsProc( HWND hwnd,
147+
BOOL CALLBACK EnumWindowsProc(HWND hwnd,
143148
LPARAM lParam
144149
)
145150
{
146151
HANDLE *data = lParam;
147152
DWORD pid;
148153
GetWindowThreadProcessId(hwnd, &pid);
149-
if (pid == data[0])
154+
if (pid == data[0] && IsMainWindow(hwnd))
150155
{
151-
PostMessage(data[1], WM_CLOSE, 0, 0);
156+
PostMessage(hwnd, WM_CLOSE, 0, 0);
152157
data[1] = hwnd;
153158
}
154159
return TRUE;

0 commit comments

Comments
 (0)