1 HWND GetDesktopHandle() 2 { 3 HWND hwndTopWindow = nullptr; 4 HWND hwndShellDefView = nullptr; 5 HWND hwndDesktop = nullptr; 6 while (hwndDesktop == nullptr) 7 { 8 hwndTopWindow = FindWindowExW(nullptr, hwndTopWindow, L"WorkerW", nullptr); 9 if (hwndTopWindow == nullptr) 10 hwndTopWindow = FindWindowExW(nullptr, hwndTopWindow, L"Progman", L"Program Manager"); 11 hwndShellDefView = FindWindowExW(hwndTopWindow, nullptr, L"SHELLDLL_DefView", nullptr); 12 if (hwndShellDefView == nullptr) 13 continue; 14 hwndDesktop = FindWindowExW(hwndShellDefView, nullptr, L"SysListView32", nullptr); 15 } 16 return hwndDesktop; 17 }
标签:hwndShellDefView,hwndTopWindow,桌面,句柄,nullptr,FindWindowExW,HWND,WIN10,hwndDeskto From: https://www.cnblogs.com/kaling/p/17128973.html