Discussion:
Shutdown dialog window handle ?
(too old to reply)
Vilius Mockûnas
2010-03-09 08:07:19 UTC
Permalink
Hello,

How do I get shutdown dialog window handle (which shows after Alt+F4) ?
After displaying the dialog user input is almost disabled so it's hard to
identify process which created the dialog, but I suspect explorer.exe.

Vilius
Dee Earley
2010-03-10 09:25:39 UTC
Permalink
Post by Vilius Mockûnas
Hello,
How do I get shutdown dialog window handle (which shows after Alt+F4) ?
After displaying the dialog user input is almost disabled so it's hard to
identify process which created the dialog, but I suspect explorer.exe.
CBT hooks.

Can I ask why you want to do this?
You r app should not be doing anything with this dialog as it is for the
USER to choose.

If you want to shut down windows, there are fully documented APIs to do it.
--
Dee Earley (***@icode.co.uk)
i-Catcher Development Team

iCode Systems
Vilius Mockunas
2010-03-10 16:25:58 UTC
Permalink
But if I want to install hook I need thread id - how do I get it in this
case ?

V
Post by Dee Earley
Post by Vilius Mockûnas
Hello,
How do I get shutdown dialog window handle (which shows after Alt+F4) ?
After displaying the dialog user input is almost disabled so it's hard to
identify process which created the dialog, but I suspect explorer.exe.
CBT hooks.
Can I ask why you want to do this?
You r app should not be doing anything with this dialog as it is for the
USER to choose.
If you want to shut down windows, there are fully documented APIs to do it.
--
i-Catcher Development Team
iCode Systems
Kerem Gümrükcü
2010-03-10 22:31:57 UTC
Permalink
What exactly do you want to do?
Why do you want to hook that dialog and
why do you want to intercept this dialog?

regards

Kerem
--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project: http://www.pro-it-education.de/software/deviceremover
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
Post by Vilius Mockunas
But if I want to install hook I need thread id - how do I get it in this
case ?
V
Post by Dee Earley
Post by Vilius Mockûnas
Hello,
How do I get shutdown dialog window handle (which shows after Alt+F4) ?
After displaying the dialog user input is almost disabled so it's hard to
identify process which created the dialog, but I suspect explorer.exe.
CBT hooks.
Can I ask why you want to do this?
You r app should not be doing anything with this dialog as it is for the
USER to choose.
If you want to shut down windows, there are fully documented APIs to do it.
--
i-Catcher Development Team
iCode Systems
Vilius Mockunas
2010-03-11 11:37:12 UTC
Permalink
Hello,

I want to shutdown explorer.exe by imitating Ctrl+Alt+Shift+"Cancel button
push by mouse"
Of course I can write my own code, but I consider this method more reliable.

V
Post by Kerem Gümrükcü
What exactly do you want to do?
Why do you want to hook that dialog and
why do you want to intercept this dialog?
regards
Kerem
--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project: http://www.pro-it-education.de/software/deviceremover
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
Post by Vilius Mockunas
But if I want to install hook I need thread id - how do I get it in this
case ?
V
Post by Dee Earley
Post by Vilius Mockûnas
Hello,
How do I get shutdown dialog window handle (which shows after Alt+F4) ?
After displaying the dialog user input is almost disabled so it's hard to
identify process which created the dialog, but I suspect explorer.exe.
CBT hooks.
Can I ask why you want to do this?
You r app should not be doing anything with this dialog as it is for the
USER to choose.
If you want to shut down windows, there are fully documented APIs to do it.
--
i-Catcher Development Team
iCode Systems
Dee Earley
2010-03-11 13:32:55 UTC
Permalink
Post by Vilius Mockûnas
Hello,
I want to shutdown explorer.exe by imitating Ctrl+Alt+Shift+"Cancel button
push by mouse"
Of course I can write my own code, but I consider this method more reliable.
What exactly are you trying to do?
You have a bad idea in your head that this is the correct solution to
something and it is not.

If you try telling us exactly what you are trying to accomplish (Just
shutting down explorer is not a good thing) we can tell you the correct
and documented way of doing it.
--
Dee Earley (***@icode.co.uk)
i-Catcher Development Team

iCode Systems
Ivo Beltchev
2010-03-11 16:37:17 UTC
Permalink
I had a similar problem but decided not to solve it. I have a shell
extension (http://classicshell.sourceforge.net/) that is installed by an
MSI file (created by a Visual Studio Setup project). During uninstall
the shell extension is in use by Explorer. It will be nice if the
uninstaller (or the installer during upgrade to a new version) can close
all Explorer processes, and relaunch Explorer when the setup is done.

I decided to give up on this because I could not find a good way to
relaunch Explorer from the installer. The installer runs as the SYSTEM
user and can't launch explorer.exe on behalf of the current user.

If somebody has figured out how to do this, I'll be very grateful if you
share :)
Post by Dee Earley
Post by Vilius Mockûnas
Hello,
I want to shutdown explorer.exe by imitating Ctrl+Alt+Shift+"Cancel button
push by mouse"
Of course I can write my own code, but I consider this method more reliable.
What exactly are you trying to do?
You have a bad idea in your head that this is the correct solution to
something and it is not.
If you try telling us exactly what you are trying to accomplish (Just
shutting down explorer is not a good thing) we can tell you the correct
and documented way of doing it.
Nobody
2010-03-11 16:55:17 UTC
Permalink
Post by Ivo Beltchev
I had a similar problem but decided not to solve it. I have a shell
extension (http://classicshell.sourceforge.net/) that is installed by an
MSI file (created by a Visual Studio Setup project). During uninstall the
shell extension is in use by Explorer. It will be nice if the uninstaller
(or the installer during upgrade to a new version) can close all Explorer
processes, and relaunch Explorer when the setup is done.
I decided to give up on this because I could not find a good way to
relaunch Explorer from the installer. The installer runs as the SYSTEM
user and can't launch explorer.exe on behalf of the current user.
If somebody has figured out how to do this, I'll be very grateful if you
share :)
It's a bad idea to close Explorer. TaskBar button are out of order, and tray
icons or missing. It's possible to run a program as the logged on user when
running as system(See CreateProcessAsUser), but it still not a good idea to
close Explorer.

Another option is to rename the inuse DLL to something temporary, then
install the replacement DLL. Renaming EXE/DLL while they are is use is
something that is supported in Windows 2000+. You can rename in use
EXE/DLL's, but you can't delete them.

In this case, you rename your DLL to something else, then install the
updated version. The new DLL will be loaded by Explorer the next time it
tries to load the DLL. I am not sure how this works with COM based DLL's
though. See this topic for details:

Dynamic-Link Library Updates
http://msdn.microsoft.com/en-us/library/ms682604(VS.85).aspx

There is also Restart Manager in Vista+:

Restart Manager:
http://msdn.microsoft.com/en-us/library/cc948910(VS.85).aspx
Ivo Beltchev
2010-03-11 17:34:46 UTC
Permalink
Post by Nobody
Post by Ivo Beltchev
I had a similar problem but decided not to solve it. I have a shell
extension (http://classicshell.sourceforge.net/) that is installed by an
MSI file (created by a Visual Studio Setup project). During uninstall the
shell extension is in use by Explorer. It will be nice if the uninstaller
(or the installer during upgrade to a new version) can close all Explorer
processes, and relaunch Explorer when the setup is done.
I decided to give up on this because I could not find a good way to
relaunch Explorer from the installer. The installer runs as the SYSTEM
user and can't launch explorer.exe on behalf of the current user.
If somebody has figured out how to do this, I'll be very grateful if you
share :)
It's a bad idea to close Explorer. TaskBar button are out of order, and tray
icons or missing. It's possible to run a program as the logged on user when
running as system(See CreateProcessAsUser), but it still not a good idea to
close Explorer.
Another option is to rename the inuse DLL to something temporary, then
install the replacement DLL. Renaming EXE/DLL while they are is use is
something that is supported in Windows 2000+. You can rename in use
EXE/DLL's, but you can't delete them.
In this case, you rename your DLL to something else, then install the
updated version. The new DLL will be loaded by Explorer the next time it
tries to load the DLL. I am not sure how this works with COM based DLL's
Dynamic-Link Library Updates
http://msdn.microsoft.com/en-us/library/ms682604(VS.85).aspx
http://msdn.microsoft.com/en-us/library/cc948910(VS.85).aspx
Yes, I know all that, but users still complain that they have to log
off. Also when upgrading to a new version sometimes both the new DLL and
the old DLL get loaded by Explorer - hilarity ensues. And the Restart
Manager is kind of flaky too. Sometimes it detects the dependency and
renames the files, other times it does not.

That said, my current "solution" is indeed to do nothing and rely on the
Restart Manager. But I'm not satisfied how it behaves sometimes.
Nobody
2010-03-11 18:13:05 UTC
Permalink
Yes, I know all that, but users still complain that they have to log off.
Also when upgrading to a new version sometimes both the new DLL and the
old DLL get loaded by Explorer - hilarity ensues. And the Restart Manager
is kind of flaky too. Sometimes it detects the dependency and renames the
files, other times it does not.
That said, my current "solution" is indeed to do nothing and rely on the
Restart Manager. But I'm not satisfied how it behaves sometimes.
It seems that terminating Explorer process would solve this problem if the
user agrees to it. It's possible to rearrange task bar buttons by using
undocumented methods, but it's a hack. See this link

ButtonBoogie 2: Rearrange Your Taskbar Buttons
http://www.pcmag.com/article2/0,2817,1901633,00.asp

Unfortunately it's for subscriber only. If you search the web for
"ButtonBoogie2.zip", you might find it a copy of it. The way it works is by
installing a hook and monitor or send messages that are found through a tool
like Spy++, so you can do the same if you have Spy++ or similar tool. This
means that your solution could break in future versions of the OS.
Ivo Beltchev
2010-03-11 16:29:28 UTC
Permalink
You can try to locate the top-level window with class "Progman" and post
WM_QUIT to it. Keep in mind that sometimes there are 2 explorer
processes that are running - one for the Desktop/taskbar and one for the
Explorer windows. Also on 64-bit Vista there may be a 32-bit Explorer
also running (if a 32-bit process has launched "explorer.exe").
Post by Vilius Mockûnas
Hello,
I want to shutdown explorer.exe by imitating Ctrl+Alt+Shift+"Cancel button
push by mouse"
Of course I can write my own code, but I consider this method more reliable.
V
Post by Kerem Gümrükcü
What exactly do you want to do?
Why do you want to hook that dialog and
why do you want to intercept this dialog?
regards
Kerem
--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project: http://www.pro-it-education.de/software/deviceremover
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
Post by Vilius Mockunas
But if I want to install hook I need thread id - how do I get it in this
case ?
V
Post by Dee Earley
Post by Vilius Mockûnas
Hello,
How do I get shutdown dialog window handle (which shows after Alt+F4) ?
After displaying the dialog user input is almost disabled so it's hard to
identify process which created the dialog, but I suspect explorer.exe.
CBT hooks.
Can I ask why you want to do this?
You r app should not be doing anything with this dialog as it is for the
USER to choose.
If you want to shut down windows, there are fully documented APIs to do it.
--
i-Catcher Development Team
iCode Systems
m
2010-03-12 00:06:56 UTC
Permalink
Remember that there is also an option to run _each_ explorer window in a
separate process. My guess is that this is used mostly for shell debugging,
but it is an important consideration.

In general what the OP is doing is just wrong, and IMHO there is no reliable
way to deal with the installation / un-installation of shell extensions
except reboot (think terminal services) and I can think of no other
legitimate reason for wanting to restart explorer from a program.
Post by Ivo Beltchev
You can try to locate the top-level window with class "Progman" and post
WM_QUIT to it. Keep in mind that sometimes there are 2 explorer processes
that are running - one for the Desktop/taskbar and one for the Explorer
windows. Also on 64-bit Vista there may be a 32-bit Explorer also running
(if a 32-bit process has launched "explorer.exe").
Post by Vilius Mockûnas
Hello,
I want to shutdown explorer.exe by imitating Ctrl+Alt+Shift+"Cancel
button push by mouse"
Of course I can write my own code, but I consider this method more reliable.
V
Post by Kerem Gümrükcü
What exactly do you want to do?
Why do you want to hook that dialog and
why do you want to intercept this dialog?
regards
Kerem
--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project: http://www.pro-it-education.de/software/deviceremover
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
Post by Vilius Mockunas
But if I want to install hook I need thread id - how do I get it in
this case ?
V
Post by Dee Earley
Post by Vilius Mockûnas
Hello,
How do I get shutdown dialog window handle (which shows after Alt+F4) ?
After displaying the dialog user input is almost disabled so it's hard to
identify process which created the dialog, but I suspect
explorer.exe.
CBT hooks.
Can I ask why you want to do this?
You r app should not be doing anything with this dialog as it is for
the USER to choose.
If you want to shut down windows, there are fully documented APIs to do it.
--
i-Catcher Development Team
iCode Systems
Loading...