GetActiveWindow() will return the HWND to the current active window. I don't know if this is the best answer for your problem though. Are you creating the window inside the dll or just trying to call GetWindowRect() in a dll function? If the latter then perhaps add a parameter for HWND?