Madshi
asked on
stop explorer cleanly
How can I stop the explorer (= startmenu + desktop) cleanly without any user interaction?
In the moment I'm using TerminateProcess, but after some stops&starts the win9x PCs get instable.
But I can logoff and logon again 1000 times without any problems. So there must be a way to stop the explorer cleanly.
But: I don't want to logoff! I just want to stop the explorer!
(It's for a remote control software, that fully controls a client PC).
I need it for all win9x versions, NT4 and win2000.
Thank you... :-)
In the moment I'm using TerminateProcess, but after some stops&starts the win9x PCs get instable.
But I can logoff and logon again 1000 times without any problems. So there must be a way to stop the explorer cleanly.
But: I don't want to logoff! I just want to stop the explorer!
(It's for a remote control software, that fully controls a client PC).
I need it for all win9x versions, NT4 and win2000.
Thank you... :-)
Hi Madshi,
Only thing I found about it is an article in MSDN ID: Q216638 'HOWTO: Programmatically Force Windows 95 and Windows 98 to Log Off' ... did you see this before?
This article even describes how to stop explorer process using TerminateProcess.
ZOPPO
Only thing I found about it is an article in MSDN ID: Q216638 'HOWTO: Programmatically Force Windows 95 and Windows 98 to Log Off' ... did you see this before?
This article even describes how to stop explorer process using TerminateProcess.
ZOPPO
But, unfortunately, the used ToolHelp-function won't work with NT4 or earlier...
ASKER
Hi Zoppo, thanx for your input. But as I said, I'm already using TerminateProcess to stop the explorer, and after doing that several times, win9x PCs get instable somehow... :-(
listening ....
Ok, I have some ideas but it's not exactly what you want. If you go in to "Shut Down" dialog and pres Ctrl+Alt+Shift and click on Cancel button the explorer will go out. So, probably you can use something like Spy or whatever and check what is happening, probably there is some spesial message. As I know such way exist only on win9x (with dialog and such key combination).
ASKER
Hey, nice trick! :-) I didn't know that before.
Hmmm... Would you test that for me? That would be great! (I don't have Spy on my harddisk.)
Well, even if it only works for win9x, that would help me a lot already. So I would be willing to give you those points, if you find a special message that works under all win9x versions.
Thank you...
Regards, Madshi.
Hmmm... Would you test that for me? That would be great! (I don't have Spy on my harddisk.)
Well, even if it only works for win9x, that would help me a lot already. So I would be willing to give you those points, if you find a special message that works under all win9x versions.
Thank you...
Regards, Madshi.
Ok, I gonna try
Here it is:
HWND hwnd = ::FindWindow("Shell_TrayWn d", NULL);
if(hwnd)
::PostMessage(hwnd, WM_QUIT, 0, 0);
HWND hwnd = ::FindWindow("Shell_TrayWn
if(hwnd)
::PostMessage(hwnd, WM_QUIT, 0, 0);
It also works under w2k :)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
i ONLY think that ...
HWND hwndShell = FindWindow("Shell_TrayWnd" , NULL);
PostMessage(hwndShell, WM_QUIT, 0, 0L);
WinExec("Explorer.exe",SW_ SHOW);
will do the Job !!
HWND hwndShell = FindWindow("Shell_TrayWnd"
PostMessage(hwndShell, WM_QUIT, 0, 0L);
WinExec("Explorer.exe",SW_
will do the Job !!
Listening....
The truth is that Explorer sends two messages as a response on Shift-Control-Alt+Cancel:
PostMessage("Progman",WM_Q UIT,0,1)
PostMessage("Shell_TrayWnd ",WM_QUIT, 0,0)
on my NT, at least.
PostMessage("Progman",WM_Q
PostMessage("Shell_TrayWnd
on my NT, at least.
Probably, Progman sends the WM_QUIT message to Shell_TrayWnd when it quits.
No, right after the DialogBoxParam() there are two adjacent PostMessage calls.
Seems that it doesn't matter anyway and WM_QUIT may be sent to the one of them.
Of course, it's better to follow the MS knowledge base article.
Seems that it doesn't matter anyway and WM_QUIT may be sent to the one of them.
Of course, it's better to follow the MS knowledge base article.
ASKER
Thank you, guys. I'm using PostMessage(Progman, WM_QUIT, 0, 0) now and it works quite nice under win95, win98, win2000. Didn't test NT4, but I'm quite sure that it will work there, too.
Now it's a bit difficult for me to decide who should get the points.
I would like to split them between MichaelS and chensu, because Michael was the first one, and chensu gave me that "official" article (chensu, it seems to me you have an article for EVERY problem... :-).
Would that be alright for all of you?
Nick, I tried PostMessage(Progman, WM_QUIT, 0, 1), too. Strange thing! It opens the shutdown dialog!!! #8-O
Regards, Madshi.
Now it's a bit difficult for me to decide who should get the points.
I would like to split them between MichaelS and chensu, because Michael was the first one, and chensu gave me that "official" article (chensu, it seems to me you have an article for EVERY problem... :-).
Would that be alright for all of you?
Nick, I tried PostMessage(Progman, WM_QUIT, 0, 1), too. Strange thing! It opens the shutdown dialog!!! #8-O
Regards, Madshi.
>>I tried PostMessage(Progman, WM_QUIT, 0, 1), too. Strange thing! It opens the shutdown dialog!!!
Really? Have you tried both PostMessages, one right after another?
Anyway, it doesn't matter, my comment doesn't pretend on answer.
Really? Have you tried both PostMessages, one right after another?
Anyway, it doesn't matter, my comment doesn't pretend on answer.
listening...
Community Support has reduced points from 333 to 200
Hello everyone,
Reducing points to 200 to allow for split.
Madshi, you can now accept one of the comments in this thread as an answer. To award the other Expert, you can create a new question in this topic area with a title of 'For ExpertName -- 10507038' using that Experts username.
Remember, the Accept Comment as Answer button is in the header of the comment.
For your convenience, you can use this link to create the new question (right click and open in a new window):
https://www.experts-exchange.com/bin/NewQForm?ta=45
darinw
Customer Service
Reducing points to 200 to allow for split.
Madshi, you can now accept one of the comments in this thread as an answer. To award the other Expert, you can create a new question in this topic area with a title of 'For ExpertName -- 10507038' using that Experts username.
Remember, the Accept Comment as Answer button is in the header of the comment.
For your convenience, you can use this link to create the new question (right click and open in a new window):
https://www.experts-exchange.com/bin/NewQForm?ta=45
darinw
Customer Service
ASKER
Comment accepted as answer
ASKER
Thank you all for your help!
ASKER