Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#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

This comment has been minimized.

Copy link
Owner Author

@m417z m417z commented Dec 24, 2020

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