任何时刻,只有一个当前窗口,那如何得到它的句柄.当前窗口可能不是本进程的窗口.GetActiveWindow行不通吧?
HWND hwnd = ::GetWindow(NULL);
GetWindow
The GetWindow function examines the Z order of the child windows associated with the specified parent window and retrieves a handle to the child window at the top of the Z order.
HWND GetWindow(
HWND hWnd // handle to parent window
);
Parameters
hWnd
Handle to the parent window whose child windows are to be examined. If this parameter is NULL, the function returns a handle to the window at the top of the Z order.
GetForegroundWindow
The GetForegroundWindow function returns a handle to the foreground window (the window with which the user is currently working). The system assigns a slightly higher priority to the thread that creates the foreground window than it does to other threads.
HWND GetForegroundWindow(VOID)
GetWindow