BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Windows Shutdown Replacement

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API)
View previous topic :: View next topic  
Author Message
Tom
Guest





PostPosted: Sat Dec 24, 2005 11:57 am    Post subject: Windows Shutdown Replacement Reply with quote



Is it possible to run the application which I made when user cliks on
Start->Turn Off Computer instead of windows shutdown?
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Sun Dec 25, 2005 8:57 am    Post subject: Re: Windows Shutdown Replacement Reply with quote




"Tom" <tom (AT) net (DOT) com> wrote


Quote:
Is it possible to run the application which I made when user
cliks on Start->Turn Off Computer instead of windows shutdown?

No. That operation is built into the OS. It is not a program that you can
replace. What you can do is have your program already running before the
shutdown occurs, and then respond to the shutdown request by intercepting
the WM_QUERYENDSESSION and/or WM_ENDSESSION message. Or else have your
program initiate the shutdown in the first place instead of the user
clicking on the start menu at all.


Gambit



Back to top
Tom
Guest





PostPosted: Mon Dec 26, 2005 11:54 am    Post subject: Re: Windows Shutdown Replacement Reply with quote



Too bad, thanx anyway. I thought it's possible to replace the standard
shutdown dialog with three options Stand By, Shutdown and Restart with
my application. Something like Task Switch, which replaces the standard
Alt+Tab dialog.


Remy Lebeau (TeamB) wrote:
Quote:
"Tom" <tom (AT) net (DOT) com> wrote



Is it possible to run the application which I made when user
cliks on Start->Turn Off Computer instead of windows shutdown?


No. That operation is built into the OS. It is not a program that you can
replace. What you can do is have your program already running before the
shutdown occurs, and then respond to the shutdown request by intercepting
the WM_QUERYENDSESSION and/or WM_ENDSESSION message. Or else have your
program initiate the shutdown in the first place instead of the user
clicking on the start menu at all.


Gambit



Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed Dec 28, 2005 9:20 am    Post subject: Re: Windows Shutdown Replacement Reply with quote


"Tom" <tom (AT) net (DOT) com> wrote


Quote:
I thought it's possible to replace the standard shutdown dialog
with three options Stand By, Shutdown and Restart with my application.

Why would you want to do that, though?


Gambit



Back to top
Tom
Guest





PostPosted: Wed Dec 28, 2005 10:10 am    Post subject: Re: Windows Shutdown Replacement Reply with quote

Because I have the same options but I also have a TimeEdit so any of
this options can be executed at desired time, and that's why I wanted to
replace the standard dialog with my application, I thought it would be
nice to call my application via Start->Turn Off Computer.
Remy Lebeau (TeamB) wrote:
Quote:
"Tom" <tom (AT) net (DOT) com> wrote in message
news:43afd98b$1 (AT) newsgroups (DOT) borland.com...


I thought it's possible to replace the standard shutdown dialog
with three options Stand By, Shutdown and Restart with my application.


Why would you want to do that, though?


Gambit



Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed Dec 28, 2005 5:50 pm    Post subject: Re: Windows Shutdown Replacement Reply with quote


"Tom" <tom (AT) net (DOT) com> wrote


Quote:
Because I have the same options but I also have a TimeEdit
so any of this options can be executed at desired time

What do you mean exactly? Are you providing a timeout value, ie "Execute
such-and-such option in NN seconds"? Or are you implementing an absolute
timer value, ie "Execute such-and-such option at NN:NN:NN AP on NN/NN/NNNN"?
If the former, then I can understand wanting to replace/augment the dialog.
But if the latter, then why not provide that type of configuration inside
your own application completely separately from the OS's dialog? Again, I
ask, what EXACTLY are you trying to accomplish?

Quote:
and that's why I wanted to replace the standard dialog with
my application, I thought it would be nice to call my application
via Start->Turn Off Computer.

Rather than replace the existing dialog altogether, you can try keeping the
existing dialog and just alter it directly as needed. Write a DLL that
calls the SetWindowsHookEx() function to install a WH_CBT hook into the OS.
When the DLL receives a HCBT_ACTIVATE notification, you can check if the
specified HWND is the dialog or not, and if so then alter it any way you
wish, such as by adding additional controls to it. You can also use a
WH_CALLWNDPROC and/or WH_CALLWNDPROCRET hook to respond to messages that are
issued for your extra controls.


Gambit



Back to top
Tom
Guest





PostPosted: Wed Dec 28, 2005 7:03 pm    Post subject: Re: Windows Shutdown Replacement Reply with quote

First I want to thank you on your effort.

My application has three radiobuttons (Stand By, Shutdown and Restart) I
also have a TEdit control in which user enters desired time to execute
selected option (format is HH:MM:SS -> for example shutdown my computer
at 19:15:00)
If I use timeout does it mean that I don't have to use TTimer control?

What I'm trying to do is not to have a shortcut on my desktop and not to
call my application by double click on the icon on the desktop or
anywhere else, but to call it by clicking on the Start->Turn Off Computer.

Altering the dialog seems to be the right way. I have to add TEdit
control which will be used for entering time (if it's left empty, action
should occur immediately and if not timer should be started). But as you
probably guessed I don't have much experience with API functions and
installing a hook, the only example I saw is installing a mouse hook
([url]http://www.leunen.com/cbuilder/hook.html)[/url], so I'll try to find some
tutorials and search on
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/WindowsUserInterface/Windowing/Hooks.asp
, to expand my knowledge. If you have any suggestions or links to
examples please tell me.

Thank you very much.


Remy Lebeau (TeamB) wrote:
Quote:
"Tom" <tom (AT) net (DOT) com> wrote in message
news:43b26430$1 (AT) newsgroups (DOT) borland.com...


Because I have the same options but I also have a TimeEdit
so any of this options can be executed at desired time


What do you mean exactly? Are you providing a timeout value, ie "Execute
such-and-such option in NN seconds"? Or are you implementing an absolute
timer value, ie "Execute such-and-such option at NN:NN:NN AP on NN/NN/NNNN"?
If the former, then I can understand wanting to replace/augment the dialog.
But if the latter, then why not provide that type of configuration inside
your own application completely separately from the OS's dialog? Again, I
ask, what EXACTLY are you trying to accomplish?


and that's why I wanted to replace the standard dialog with
my application, I thought it would be nice to call my application
via Start->Turn Off Computer.


Rather than replace the existing dialog altogether, you can try keeping the
existing dialog and just alter it directly as needed. Write a DLL that
calls the SetWindowsHookEx() function to install a WH_CBT hook into the OS.
When the DLL receives a HCBT_ACTIVATE notification, you can check if the
specified HWND is the dialog or not, and if so then alter it any way you
wish, such as by adding additional controls to it. You can also use a
WH_CALLWNDPROC and/or WH_CALLWNDPROCRET hook to respond to messages that are
issued for your extra controls.


Gambit



Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed Dec 28, 2005 7:11 pm    Post subject: Re: Windows Shutdown Replacement Reply with quote


"Tom" <tom (AT) net (DOT) com> wrote


Quote:
My application has three radiobuttons (Stand By, Shutdown and
Restart) I also have a TEdit control in which user enters desired time
to execute selected option (format is HH:MM:SS -> for example
shutdown my computer at 19:15:00)

Then I suggest you not try to replace/alter the existing shutdown dialog for
that. Provide your own configuration dialog in your application that teh
user can bring up at any time. Once the user's desired time value has been
saved, you can have the application continuously monitor the current system
time. When the configured system time arrives, call the ExitWindows/Ex()
function to perform the desired shutdown operation programmably.

Quote:
What I'm trying to do is not to have a shortcut on my desktop and
not to call my application by double click on the icon on the desktop

You could write a service that automatically runs in the background at
system startup, continuously monitoring the time. You could then provide a
separate .exe or .cpl executable for configuring the service. In the case
of the .cpl, since it becomes part of the system's Control Panel, you can
make it so only admins can run it, and thus only admins can change the time
your shutdown operation is performed. You could also specify admin
permisions to the .exe if you want to go that route instead.

Quote:
or anywhere else, but to call it by clicking on the Start->Turn Off
Computer.


Why, though? That is not necessary, and it makes things harder not only for
you, but for the user as well.


Gambit



Back to top
Tom
Guest





PostPosted: Thu Dec 29, 2005 4:29 pm    Post subject: Re: Windows Shutdown Replacement Reply with quote

Don't know what to say on your effort and persistance, except thank you
very much.

Remy Lebeau (TeamB) wrote:
Quote:
"Tom" <tom (AT) net (DOT) com> wrote



My application has three radiobuttons (Stand By, Shutdown and
Restart) I also have a TEdit control in which user enters desired time
to execute selected option (format is HH:MM:SS -> for example
shutdown my computer at 19:15:00)


Then I suggest you not try to replace/alter the existing shutdown dialog for
that. Provide your own configuration dialog in your application that teh
user can bring up at any time. Once the user's desired time value has been
saved, you can have the application continuously monitor the current system
time. When the configured system time arrives, call the ExitWindows/Ex()
function to perform the desired shutdown operation programmably.


What I'm trying to do is not to have a shortcut on my desktop and
not to call my application by double click on the icon on the desktop


You could write a service that automatically runs in the background at
system startup, continuously monitoring the time. You could then provide a
separate .exe or .cpl executable for configuring the service. In the case
of the .cpl, since it becomes part of the system's Control Panel, you can
make it so only admins can run it, and thus only admins can change the time
your shutdown operation is performed. You could also specify admin
permisions to the .exe if you want to go that route instead.


or anywhere else, but to call it by clicking on the Start->Turn Off

Computer.

Why, though? That is not necessary, and it makes things harder not only for
you, but for the user as well.


Gambit



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.