HI All
Does anyone know of the API to shut down and start up a WIndows NT, 9x OSes.....so
that I can make a program that would automatically shut and start a PC that
has a Windows OSes.
rgds,
Saiful
Printable View
HI All
Does anyone know of the API to shut down and start up a WIndows NT, 9x OSes.....so
that I can make a program that would automatically shut and start a PC that
has a Windows OSes.
rgds,
Saiful
Use the ExitWindowsEx API function to shut down Windows. I don't know how
you can start up. Be aware that using ExitWindowsEx in Windows NT is not
trivial, there is an example on support.microsoft.com.
Alan Griggs
"Saiful" <md-saifulamri_omar@hp.com> wrote:
>
>HI All
>
>Does anyone know of the API to shut down and start up a WIndows NT, 9x OSes.....so
>that I can make a program that would automatically shut and start a PC that
>has a Windows OSes.
>
>rgds,
>Saiful
Use the ExitWindowsEx API function to shut down Windows. I don't know how
you can start up. Be aware that using ExitWindowsEx in Windows NT is not
trivial, there is an example on support.microsoft.com.
Alan Griggs
"Saiful" <md-saifulamri_omar@hp.com> wrote:
>
>HI All
>
>Does anyone know of the API to shut down and start up a WIndows NT, 9x OSes.....so
>that I can make a program that would automatically shut and start a PC that
>has a Windows OSes.
>
>rgds,
>Saiful
"Saiful" <md-saifulamri_omar@hp.com> wrote in message
news:39e680fb$1@news.devx.com...
: Does anyone know of the API to shut down and start up a WIndows NT, 9x
OSes.....so
: that I can make a program that would automatically shut and start a PC
that
: has a Windows OSes.
The following from the Platform SDK may be helpful (under Base
Services\Hardware\Power Management)
Platform SDK: Hardware
System Wake-up Events
Your application can restore an On-Now capable computer that is in a
sleeping state to the working state by using a scheduled time or a device
event. This is known as a wake-up event. Use a waitable timer object to
specify the time at which the system should wake. To create the object, use
the CreateWaitableTimer function. To set the timer, use the SetWaitableTimer
function. The pDueTime parameter specifies when the timer will be signaled.
To specify that the system should wake when the timer is signaled, set the
fResume parameter to TRUE.
When the system wakes automatically because of an event (other than power
switch or user activity), the system automatically sets its idle timer to at
least 1 minute. This timer allows applications to call the
SetThreadExecutionState function to indicate that they are busy. This
enables the system to shut down without affecting the user. The following
criteria determine whether a system shutdown is needed:
a.. If the system wakes automatically, it shuts down as soon as the last
job is completed, as indicated by the process calling
SetThreadExecutionState.
b.. If the system wakes automatically, but the user provides new input
while the event is handled, the system does not shut down when the last job
finishes.
c.. If the system is on and the user is active, the system does not enter
the sleeping state.
d.. If the system is on, no applications are busy, and the user is
inactive for a long time, the system enters the sleeping state when the
timer expires.
When the system wakes automatically, the system broadcasts the
PBT_APMRESUMEAUTOMATIC event to all applications. Because the user is not
present, most applications should do nothing. Event-handling applications,
such as fax servers, should handle their events. If you wish to determine
whether the system is in this state, call the IsSystemResumeAutomatic
function.
If the system wakes due to user activity after broadcasting
PBT_APMRESUMEAUTOMATIC, the system broadcasts the PBT_APMRESUMESUSPEND event
and turns on the display. Your application should reopen files that it
closed when the system entered the sleeping state, and it should prepare for
user input.
If an application called SetSystemPowerState with fForce set to TRUE, no
applications will receive the PBT_APMQUERYSUSPEND event when the system
enters the sleeping state. If the system is carrying out a critical
suspension, no applications will receive the PBT_APMQUERYSUSPEND or
PBT_APMSUSPEND event; they will receive only the PBT_APMRESUMECRITICAL
event.
--
Damit Senanayake | damit@mvps.org | http://members.xoom.com/damit
Please reply to newsgroups, not by e-mail. | ICQ: 6930718
"Saiful" <md-saifulamri_omar@hp.com> wrote in message
news:39e680fb$1@news.devx.com...
: Does anyone know of the API to shut down and start up a WIndows NT, 9x
OSes.....so
: that I can make a program that would automatically shut and start a PC
that
: has a Windows OSes.
The following from the Platform SDK may be helpful (under Base
Services\Hardware\Power Management)
Platform SDK: Hardware
System Wake-up Events
Your application can restore an On-Now capable computer that is in a
sleeping state to the working state by using a scheduled time or a device
event. This is known as a wake-up event. Use a waitable timer object to
specify the time at which the system should wake. To create the object, use
the CreateWaitableTimer function. To set the timer, use the SetWaitableTimer
function. The pDueTime parameter specifies when the timer will be signaled.
To specify that the system should wake when the timer is signaled, set the
fResume parameter to TRUE.
When the system wakes automatically because of an event (other than power
switch or user activity), the system automatically sets its idle timer to at
least 1 minute. This timer allows applications to call the
SetThreadExecutionState function to indicate that they are busy. This
enables the system to shut down without affecting the user. The following
criteria determine whether a system shutdown is needed:
a.. If the system wakes automatically, it shuts down as soon as the last
job is completed, as indicated by the process calling
SetThreadExecutionState.
b.. If the system wakes automatically, but the user provides new input
while the event is handled, the system does not shut down when the last job
finishes.
c.. If the system is on and the user is active, the system does not enter
the sleeping state.
d.. If the system is on, no applications are busy, and the user is
inactive for a long time, the system enters the sleeping state when the
timer expires.
When the system wakes automatically, the system broadcasts the
PBT_APMRESUMEAUTOMATIC event to all applications. Because the user is not
present, most applications should do nothing. Event-handling applications,
such as fax servers, should handle their events. If you wish to determine
whether the system is in this state, call the IsSystemResumeAutomatic
function.
If the system wakes due to user activity after broadcasting
PBT_APMRESUMEAUTOMATIC, the system broadcasts the PBT_APMRESUMESUSPEND event
and turns on the display. Your application should reopen files that it
closed when the system entered the sleeping state, and it should prepare for
user input.
If an application called SetSystemPowerState with fForce set to TRUE, no
applications will receive the PBT_APMQUERYSUSPEND event when the system
enters the sleeping state. If the system is carrying out a critical
suspension, no applications will receive the PBT_APMQUERYSUSPEND or
PBT_APMSUSPEND event; they will receive only the PBT_APMRESUMECRITICAL
event.
--
Damit Senanayake | damit@mvps.org | http://members.xoom.com/damit
Please reply to newsgroups, not by e-mail. | ICQ: 6930718
Here is the code to restart or shut down Windows 9x. I am almost sure it
isn't going to work properly on NT though so use it with care.
Anthony
'In general section
Const EWX_LOGOFF = 0
Const EWX_SHUTDOWN = 1
Const EWX_REBOOT = 2
Const EWX_FORCE = 4
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long,
ByVal dwReserved As Long) As Long
Private Sub Form_Load()
msg = MsgBox("This program is going to reboot your computer. Press OK
to continue or Cancel to stop.", vbCritical + vbOKCancel + 256, App.Title)
If msg = vbCancel Then End
'reboot the computer
ret& = ExitWindowsEx(EWX_FORCE Or EWX_REBOOT, 0)
End Sub
Here is the code to restart or shut down Windows 9x. I am almost sure it
isn't going to work properly on NT though so use it with care.
Anthony
'In general section
Const EWX_LOGOFF = 0
Const EWX_SHUTDOWN = 1
Const EWX_REBOOT = 2
Const EWX_FORCE = 4
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long,
ByVal dwReserved As Long) As Long
Private Sub Form_Load()
msg = MsgBox("This program is going to reboot your computer. Press OK
to continue or Cancel to stop.", vbCritical + vbOKCancel + 256, App.Title)
If msg = vbCancel Then End
'reboot the computer
ret& = ExitWindowsEx(EWX_FORCE Or EWX_REBOOT, 0)
End Sub