Also check for executable name when restoring from tray via shortcut

This commit is contained in:
Berke Viktor 2012-06-03 14:22:51 +02:00
parent 58ca1966c8
commit 9f7f85fa5d
1 changed files with 17 additions and 10 deletions

View File

@ -914,24 +914,31 @@ xchat_restore_window (HWND xchat_window)
BOOL CALLBACK BOOL CALLBACK
enum_windows_impl (HWND current_window, LPARAM lParam) enum_windows_impl (HWND current_window, LPARAM lParam)
{ {
TCHAR buffer[10]; TCHAR window_name[10];
ZeroMemory (&buffer, sizeof (buffer)); TCHAR module_path[1024];
ZeroMemory (&window_name, sizeof (window_name));
if (!current_window) if (!current_window)
{ {
return TRUE; return TRUE;
} }
GetWindowText (current_window, buffer, 10); GetWindowText (current_window, window_name, 10);
if (stricmp (buffer, "xchat-wdk") == 0) /* We've found it, stop */ if (stricmp (window_name, "xchat-wdk") == 0)
{ {
xchat_restore_window (current_window); /* use a separate if block, this way we don't have to call GetWindowModuleFileName() for each hit */
return FALSE; ZeroMemory (&module_path, sizeof (module_path));
} GetWindowModuleFileName (current_window, module_path, sizeof (module_path));
else /* Keep searching */
{ if (strstr (module_path, "xchat.exe")) /* We've found it, stop */
return TRUE; {
xchat_restore_window (current_window);
return FALSE;
}
} }
return TRUE; /* Keep searching */
} }
#endif #endif