WaitForInputIdle waits until the process is ready to receive input, which may be before a main window handle is available. To confirm that your process definitely does expose a main window handle try just sleeping your thread for about 10 or 15 seconds before trying to get it. If there is one to get then you know it will be available by then. If you still get Zero then you know that that process simply doesn't expose a main window handle. If it does then you can just add a loop that will sleep repeatedly until a handle is available. You should apply a timeout to that though because if a browser window is already open then opening a new Web page will create a new tab within the existing main window, NOT create a new one.