I would like to know if it's possible to write a small application (and what
API do I use) and install it in Windows 98 and make power button
programmable, or at least safe shut down instead of immediate power off when
power button is pressed.
> I would like to know if it's possible to write a small application (and what
> API do I use) and install it in Windows 98 and make power button
> programmable, or at least safe shut down instead of immediate power off when
> power button is pressed.
Can you imagine a program which will make Windows shut down safely
when the power cord is yanked out from the wall socket?
D.
I think that in order to write to the CMOS memory properly, it is necessary
to process interrupts. Regardlous, it is much better to use the Windows
interface to the CMOS. I am aware of no reason not to use the Windows
functions.
I am nearly certain that the CMOS has nothing to support a power button
directly. CMOS memory certainly has a code to indicate what to do after a
system reset. It is what determines whether Ctrl-Alt-Del does a warm boot in
a DOS system.
"dnagel" <NOTGra...@hotmail.com> wrote in message
news:uEB5uocJ...@TK2MSFTNGP09.phx.gbl...
"binary100110" <binary...@yahoo.com> wrote in message
news:%23WVgLHb...@TK2MSFTNGP15.phx.gbl...
Most medium-level and virtually all high-end UPS systems provide the
ability. They usually have a serial device that is used to signal something
in the system to do a safe shutdown when (battery backup) power gets low.
When the power cord is yanked out from the wall socket, the battery backup
keeps the system up and allows the system to safely shutdown.
Yeah, I know ... I've had that at home for just under ten years now.
(I know this offhand because the battery packs need replacement, again)
My point is that no software fix can address the type of power switch hardware
that simply shuts off the computer's power supply.
Bob
If when binary100110 says "power button" what is meant is "power switch
hardware that simply shuts off the computer's power supply" then yes it is
obviously impossible to override that hardware with software. I am not sure
however that the question is that clear; what is intended might be
different.
If binary100110 does not clarify the question, then this thread will likely
grow uncontrollably, fed by confusion. I am the first to admit confusion.
The OP might be thinking that the software that the API that
powers the system down/restarts the system actually presses
a button. <g> The API call can be found at Randy Birch's web:
http://vbnet.mvps.org/code/shell/undocshelldlgs.htm
http://vbnet.mvps.org/code/system/exitwindowsex.htm
http://vbnet.mvps.org/code/system/initiatesystemshutdown.htm
Hope that helps.
--
Jim Carlock
Please post replies to newsgroup.
If it is the API function that is the answer then the question needs to be
asked more directly. Probably the power button or the power key is not
relevant to the answer.
If it is the power key and not a power button then calling it a button (in
the original question) contributes to the confusion.
> The OP might be thinking that the software that the API that
> powers the system down/restarts the system actually presses
> a button. <g>
Yeah, some people prefer to reverse-engineer stuff instead of RTFM (Reading
The Fantastic Manual).
> The API call can be found at Randy Birch's web:
> http://vbnet.mvps.org/code/shell/undocshelldlgs.htm
> http://vbnet.mvps.org/code/system/exitwindowsex.htm
> http://vbnet.mvps.org/code/system/initiatesystemshutdown.htm
Yeah, ExitWindowsEx is a likely answer, and if so, then the power key or
power button is an indirect way of asking. A more direct way to ask is to
search the titles only of the Platform SDK for "shutdown".
> management in Win XP so that whenever the user pressed the power button
on
> system unit, Win 98 will go through the standard shutting down procedure.
It is not possible to tell something about this that is valid for all
computers since this option depends on the features implemented by the
motherboard manufacturer. Even with XP this option does not every time what
it claims to do. AFAIK the best way is to look up the computers BIOS setup
for such a setting and choose the desired option there.
--
----------------------------------------------------------------------
THORSTEN ALBERS Universität Freiburg
albers@
uni-freiburg.de
----------------------------------------------------------------------
Probably that is a better description of what you intend to ask.
My system is old enough that it does not have an ATX power supply. Therefore
my system works the old-style way; the power button does truly turn the
power on/off.
ATX is a standard that specifies how the power supply interfaces with the
system board (mother board) and the operating system. I don't know the
details of how the ATX standard works, especially since I don't use it.
However it probably will be worthwhile for you to become familiar with it.
I am not sure I undestand what you mean by "act as the power button
management in Win XP". However I think what you are saying is that you want
to prevent the hardware power button from turning off the power without
first doing a system shutdown. If so, then I thought that is how ATX systems
work by default.
I am assuming that the systems use an ATX power supply and system board. If
they do, then I would attempt to determine if there is something ATX
standard about system boards that could be modified to do what you need
done. More specifically, it might be true that an ATX power supply button
might not turn power off but might instead send a signal of some type to the
system board that the operating system responds to, which is the reverse of
Windows sending a signal that causes the power supply to actually turn off.
1) Never assume anything. It's a bad habbit to get into.
2) Almost all systems today are ATX.
An ATX power switch is called a momentary switch if you're
a hardware guru. Basically it doesn't turn the system off UNLESS
you hold it in for a certain period of time. Some ATX systems
have a second power switch as well. These are usually found on
the power supply themselves (visible if you look at the back of
the power supply). That second switch is a toggle switch (on or
off).
The momentary switch connects to the motherboard via two
connectors. When it's pressed it closes the gap and shorts the
circuit. The firmware (BIOS) starts counting (usually to 4) and
once it hits 4 seconds it'll turn the system off.
Now... every now and then you'll run into a funny BIOS which
is set up to automatically restart the system when the system
powers off.
And... everyone now and then you'll run into a system that has
a power "key" on the keyboard. That funny power "key" sends
a signal to the operating system, so you don't have to hold it for
four seconds. So in that case it's the operating system that does
the power off. The bad thing about the key on the keyboard is
that if you are busy working and you reach up to the F10 key
for some reason and miss...
Everyone, including you, continuously make thousands of assumptions. For
example, we assume the sky won't fall on us, although it might. If we don't
assume the sky won't fall, then we should stay indoors forever.
Darn... that reminds me.... gotta call the roofer when I get home <g> The
rains this year creamed my roof.
--
Ken Halter - MS-MVP-VB - http://www.vbsight.com
Sign up now to help keep VB support alive - http://classicvb.org/petition
Please keep all discussions in the groups..
What's to assume? You ever been hit by bird poop?
--
Jim Carlock
Please post replies to newsgroup.
"Ken Halter" wrote:
Me not!
> If we don't assume the sky won't fall, then we should stay indoors
forever.
Of what help would that be?
D.
Perhaps the reason you say this about me and only me is because my replies
are especially relevant and reassonable.
I am surprised by the amount of messages that are as negative and critical
as there are. I often respond to messages that are that way, as I did in
this thread. What the original question asked for might not be possible, but
Bob's reply was more than what was necessary. If you want to avoid getting
the kind of response I posted, then just don't be so critical.
"dnagel" <NOTGra...@hotmail.com> wrote in message
news:uEwzEtqJ...@TK2MSFTNGP09.phx.gbl...
I used a non-sensical example since I knew there would be some kind of
criticism such as this.
Or did you really think I was serious? Do you really think the sky can
actually fall?
If not, then this is just another critical message that accomplishes nothing
except criticize.
Did You really think I was?
> Do you really think the sky can actually fall?
I some way - yes.
Well, first you need to define theSky.
Option Explicit
'Let's keep it simple
Private Type typTheSky
IsFalling As Boolean
X As Long
Y As Long 'we only care about one particular Y coordinate of the sky
Z As Long
End Type
Private Type typYou
Name As String
Y As Long 'we'll not worry about other positions
End Type
Private theSky As typTheSky
Private you As typYou
Private Sub Form_Load()
Dim i As Long
theSky.X = 1 'theSky is everywhere except point 0
theSky.Y = 1 'theSky is everywhere except point 0
theSky.Z = 1 'theSky is everywhere, except point 0
'point 0 is any object inside the sky (space)
'the interesting thing is that the sky IS constantly moving.
'once an object is in a spot where the sky was, that spot
'can not be called the sky anymore, because we define the
'sky as empty space to simplify things.
'So the question we must ask, is which way does empty
'space move? It's based upon time, and it does move, so it
'has a velocity. And if it changes directions, it has an acceleration.
'So if you can slow empty space down, you decelerate empty
'space. If it can accelerate, it can decelerate as well. Deceleration
'generally means a change in speed as opposed to a change in
'direction. Where does it go? It still exists because it comes back
'the moment an object moves out of the empty space and the
'empty space redefines itself. So we will say empty space follows
'all objects. If an object is falling, empty space is following, the
'sky is following. If any object is falling, the sky is falling. To
'illustrate...
you = "Sam Hobbs on a cliff"
Call YouJump(you)
End Sub
Private Sub YouJump(oJumper As typYou)
Dim Y As Long, YY As Long
'YY will hold the one particular area of the sky that follows a jumper
'down
If Right$(oJumper.Name, 10) = " on a cliff"
For Y = oJumper.Z To 0 Step -1
theSky.Y = oJumper.Y + 1 'theSky will occupy the area behind you
Text1.Text = Text1.Text & "theSky.Y = " & CStr(theSky.Y) & vbCrLf
Next Y
End If
End Sub
As you can see the sky follows you on the way down. The sky "really"
does fall. We took the simple way out by calling the sky the vacuum
we live in. You can make it alot more complicated if you like, but I'll
leave that up to you.
"dnagel" <NOTGra...@hotmail.com>
???????:uEB5uocJ...@TK2MSFTNGP09.phx.gbl...
"Sam Hobbs" <sam...@social.rr.com_change_social_to_socal> 撰寫於郵件新聞:uAH%23HkhJF...@TK2MSFTNGP12.phx.gbl...
http://vbnet.mvps.org/code/system/exitwindowsex.htm
There are a couple hiccups you need to take into consideration
when you're messing around with... like, do you want to provide
the user an opportunity to save unsaved work? For instance, if you
have notepad opened that hasn't been saved, do you want to give
the ability to cancel the shutdown, etc. I'm think the link above
addresses that issue, although I haven't personally messed with it
in a couple of years.
It doesn't really push the power button in any manner. Even the
keyboard shut down doesn't do that. Sometimes the BIOS is set up
to do a cold shutdown if you hold the momentary button in for four
seconds. Some systems like Compaq might save the session state
in firmware when the power button is pressed so that when the
system is turned back on, the system would supposedly return
to the state it was in when the power button was hit. The API
above though works the same on most systems (if not all systems).
--
Jim Carlock
Please post replies to newsgroup.
"binary100110" wrote:
Yes, it's the power "button"/momentary switch on system case I am referring
to. :-)
I am not sure if the power key on keyboard works the same as the momentary
switch on system case. But in any case, what I am trying to find out is that
if Win 98 supports the shut down feature/behaviour that Win XP does, and
the API function(s) for the feature/behaviour.
"Sam Hobbs" wrote:
>Yes, it's the power "button"/momentary switch on system case I am referring
>to. :-)
>I am not sure if the power key on keyboard works the same as the momentary
>switch on system case. But in any case, what I am trying to find out is that
>if Win 98 supports the shut down feature/behaviour that Win XP does, and
>the API function(s) for the feature/behaviour.
If you mean :-
Does Win98 support turning off the computer from code ?
The answer is Yes.
It is even a little simpler than under NT/2k/XP
This is assuming that you are using an AT (ATX) PSU. If you have a XT PSU
then it will sit at the "Please switch Off" Screen.
Let me try to clear things out, I think I've lead the question into what I
wasn't intended to ask.
To make the question simplier and shorter, it would read like:
"Can Win98 intercept the signal that is sent when power button on system
unit (assume it's ATX) is pressed and respond accordingly?"
Why I ask this question is because XP allows user to choose what computer
should react when the power button on the system case is pressed, as if XP
can capture the signal and gain control over it.
For those who don't understand, currently running XP and would like to find
this setting...
Go to "Start -> Settings -> Control Panel -> Power Options -> Advancded
Tab -> Power buttons frame". :-)
I know how to use API to shut computer down, but what I am looking for is
the possibly existing API that does the signal capture and control in XP.
Apologies for my bad English. :-/
> should react when the power button on the system case is pressed, as if
XP
> can capture the signal and gain control over it.
> For those who don't understand, currently running XP and would like to
find
> this setting...
> Go to "Start -> Settings -> Control Panel -> Power Options -> Advancded
> Tab -> Power buttons frame". :-)
Yes, Windows 98 can, but only if the mainboard provides this feature (>=
ATX).
To set this option in Windows 98 use "Start -> Settings -> Control Panel ->
Power Options -> Settings -> When I press the power button on my computer:
Stand By/Power Off" (maybe the exact label and option name is a bit
different, since I have translated it from a german Windows 98).
If the mainboard doesn't provide this feature or if it doesn't inform
Windows 98 correctly that it provides this feature >Windows 98 doesn't show
this option<. (If the mainboard does provide a sleep button etc., Windows
98 may show another option namend something like "When I press the sleep
button on my computer"...)
I don't think there is an API call to change this setting since it is a
global system setting, not a setting to be changed by single applications.
AFAIK the respective registry key is:
HKEY_CURRENT_USER\ControlPanel\PowerCfg
There You have a tree branch \PowerCfg\GlobalPowerPolicies with a key
"Policies" which AFAIK does apply if no named power control scheme does
exist.
Otherwise in \PowerCfg You have a key named "CurrentPowerPolicy" with a
string key value which holds the number of the named power control scheme.
This number refers to the respective scheme in the tree branch
\PowerCfg\PowerPolicies, e.g. \PowerCfg\PowerPolicies\1. There You have
also a key "Policies" which holds the current power settings of this
scheme.
The value of "Policies" is a binary value. Unfortunately I can't tell the
meaning of each byte. AFAIK the 4th and 16th byte (starting from 0) do
control the behaviour of the power switch. You will have to try out this...
> I know how to use API to shut computer down, but what I am looking for is
> the possibly existing API that does the signal capture and control in XP.
Maybe it is possible to change the setting by use of RunDLL. But I don't
know if there is an API call.
If You would like Your application to be informed about the pressing of the
power switch Your application AFAIK should use subclassing and look out for
the window message WM_POWERBROADCAST.
Definitely.
> you = "Sam Hobbs on a cliff"
> Call YouJump(you)
If this says I would jump off a cliff, and if that is somehow related to the
definition of the Sky, then you have the wrong definition of the Sky.
http://www.webopedia.com/TERM/C/CMOS.html
http://dotnetjunkies.com/WebLog/unknownreference/articles/12284.aspx
"binary100110" <binary...@thisemaildoesnotexist.com> wrote in message
news:ONnWFrBK...@TK2MSFTNGP10.phx.gbl...
If I understand what you are asking, then you probably should leave out
(exclude) the "and respond accordingly" part.
I think you are actually asking two questions that are relativley
independent of each other. It is clear you are asking if Win98 can intercept
the event of the power button on the system unit being pushed. Are you also
asking if it is possible to do a shutdown of Windows programmaticaly? If
that is the second part of your question, then it probably is (should be) a
second question and combining the two questions is causing confusion.