rbulph Posted April 26, 2010 Posted April 26, 2010 I'm using SendMessage with WM_CLOSE to close some Firefox windows. I have several Firefox windows open concurrently and it's easier to do it like this than by closing the windows manually. But, while SendMessage closes the windows, it doesn't actually seem to shut Firefox down. Firefox continues to be shown in the Task Manager. This leads to errors when I want to reopen Firefox. How do I ensure that Firefox closes when I close all of its windows? Quote
Administrators PlausiblyDamp Posted April 26, 2010 Administrators Posted April 26, 2010 Have you tried sending a WM_QUIT to firefox? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
rbulph Posted August 22, 2010 Author Posted August 22, 2010 Hmm, now it's stopped working. Here's my code: SendMessage(hwnd, WM_CLOSE,0,0) SendMessage(hwnd, WM_QUIT,0,0) I have several Firefox windows running and do this for every one that I close. If I've closed them all, and then want to open a new window, I often get a message that Firefox is still running and that I must close the existing process before I open a new one. When I look in the Task Manager it's still showing even though there are no windows visible. Any ideas? Quote
Leaders snarfblam Posted August 23, 2010 Leaders Posted August 23, 2010 I don't know if this could be related to your issue, but sometimes when I close firefox it keeps running in the background for a while. I see this behavior on multiple machines. I assume it's doing some some house-keeping. Eventually it does close itself. Quote [sIGPIC]e[/sIGPIC]
rbulph Posted August 24, 2010 Author Posted August 24, 2010 Thanks. If it wants to do that it's OK, I don't mind waiting. But is there any way of checking in code whether or not it has closed, so that I don't reopen it while it's still running and get the errors that I'm getting? Quote
Leaders snarfblam Posted August 24, 2010 Leaders Posted August 24, 2010 You could periodically enumerate the processes and see if firefox.exe is among them. I think the Process class has a method named GetProcesses. Quote [sIGPIC]e[/sIGPIC]
rbulph Posted August 25, 2010 Author Posted August 25, 2010 You could periodically enumerate the processes and see if firefox.exe is among them. I think the Process class has a method named GetProcesses. Thanks. It in fact has a method called GetProcessesByName, so this is all quite easy to do. If I've closed all windows and the process is still there, I just call its Kill method. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.