Im trying to find the foreground window, using GetForegroundWindow, and then getting its Title using GetWindowText.

The problem is that GetForegroundWindow returns a Long, like 3989, for example, but I need to specify the hWnd of the window in the GetWindowText function to get its title.

How do I get the hWnd of the window using the number?

DocUK