Anyboby知道如何獲得創建窗口的文本?我在CreateWindow
上設置了鉤子,但是GetWindowText
返回空字符串。SetWindowsHookEx HCBT_CREATEWND GetWindowText
hCBTHook = SetWindowsHookEx(WH_CBT, (HOOKPROC) &CBTHook, g_appInstance, 0);
LRESULT CALLBACK CBTHook(int nCode, WPARAM wParam, LPARAM lParam)
{
if(nCode == HCBT_CREATEWND)
{
HWND hwnd = (HWND)wParam;
CHAR buf[256];
GetWindowText(hwnd, buf, 256);
}
return CallNextHookEx(hCBTHook, nCode, wParam, lParam);
}
Accessiblility掛鉤對這類事情的工作要好得多。 – 2012-03-18 19:50:27