Use FindWindow() to find the handle of the main Window for application B. You need to know either the window title or the class name of the window of application B to pass it to FindWindow(). This will return the handle of the window for B.