XP:

//桌面的ListView控件是ProgMan窗口的孙子窗口
hWndLV = GetFirstChild(GetFirstChild(FindWindow(TEXT("ProgMan"),NULL)));
Win8:

HWND GetDestopListViewHandle(){ HWND hWnd = NULL,hWndItem; HWND hWndParent = FindWindowEx(0,0,TEXT("WorkerW"),NULL); while (hWndParent && (!hWnd)){ hWndItem = FindWindowEx(hWndParent, 0, TEXT("SHELLDLL_DefView"), NULL); if (hWndItem){ hWnd = FindWindowEx(hWndItem, 0, TEXT("SysListView32"), TEXT("FolderView")); break; } hWndParent = FindWindowEx(0, hWndParent, TEXT("WorkerW"), NULL); } return hWnd; }
本文介绍了在XP和Win8系统下如何通过Win32API获取桌面ListView控件的窗口句柄。在XP中,ListView控件是ProgMan窗口的孙子窗口,可以使用GetFirstChild两次来获取;而在Win8系统中,方法可能有所不同。
1379

被折叠的 条评论
为什么被折叠?



