Skip to content

Instantly share code, notes, and snippets.

@m417z
Created December 24, 2020 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m417z/2ef1273f7998b458c4d4c1002c8f3586 to your computer and use it in GitHub Desktop.
Save m417z/2ef1273f7998b458c4d4c1002c8f3586 to your computer and use it in GitHub Desktop.
#include <windows.h>
BOOL CALLBACK WndEnumProc(HWND hWnd, LPARAM lParam)
{
WCHAR szClassName[16];
if (GetClassName(hWnd, szClassName, _countof(szClassName)) == 0)
return TRUE;
if (lstrcmp(szClassName, L"WorkerW") != 0)
return TRUE;
HWND hChildWnd = FindWindowEx(hWnd, NULL, L"SHELLDLL_DefView", NULL);
if (!hChildWnd)
return TRUE;
*(HWND *)lParam = hChildWnd;
return FALSE;
}
int main()
{
HWND hParentWnd = FindWindow(L"Progman", NULL);
if (!hParentWnd)
return 1;
HWND hChildWnd = FindWindowEx(hParentWnd, NULL, L"SHELLDLL_DefView", NULL);
if (!hChildWnd)
{
DWORD dwThreadId = GetWindowThreadProcessId(hParentWnd, NULL);
EnumThreadWindows(dwThreadId, WndEnumProc, (LPARAM)&hChildWnd);
}
if (!hChildWnd)
return 2;
PostMessage(hChildWnd, WM_COMMAND, 0x7402, 0);
return 0;
}
@m417z
Copy link
Author

m417z commented Dec 24, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment