| View previous topic :: View next topic |
| Author |
Message |
raushan2007 Expert Cheater
Reputation: 0
Joined: 06 Nov 2007 Posts: 130
|
Posted: Thu Feb 07, 2008 12:04 pm Post subject: Shutdown according to time |
|
|
Hello,
i want to know how to shutdown my computer. I mean if the time is above 11pm then it will shutdown automatically. i hope that explains
|
|
| Back to top |
|
 |
HolyBlah Master Cheater
Reputation: 2
Joined: 24 Aug 2007 Posts: 446
|
Posted: Thu Feb 07, 2008 12:12 pm Post subject: |
|
|
| Create a program thats check the time and if it 11 run shutdown.exe.
|
|
| Back to top |
|
 |
raushan2007 Expert Cheater
Reputation: 0
Joined: 06 Nov 2007 Posts: 130
|
Posted: Thu Feb 07, 2008 12:13 pm Post subject: |
|
|
| HolyBlah wrote: | | Create a program thats check the time and if it 11 run shutdown.exe. |
Whats the code? i want it to see if the time is above 11pm
|
|
| Back to top |
|
 |
HolyBlah Master Cheater
Reputation: 2
Joined: 24 Aug 2007 Posts: 446
|
Posted: Thu Feb 07, 2008 12:22 pm Post subject: |
|
|
I can give you functions and hints, but not the full code:
1. use a Timer.
2. Use GetLocalTime to get the full date and extract the time from SYSTEMTIME structure.
Last edited by HolyBlah on Thu Feb 07, 2008 2:16 pm; edited 1 time in total |
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Thu Feb 07, 2008 12:25 pm Post subject: |
|
|
like he said above
use a timer
or you can create a seperate thread for it (CreateThread)
but i just used get system time
C++:
| Code: |
SYSTEMTIME lpSystemTime;
GetSystemTime( lpSystemTime );
if ( lpSystemTime.wHour >= 23 ) // 23 = 11 PM
// Do Shutdown command here!
|
sorry, to lazy to look up the paramaters for CreateProcess
_________________
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Thu Feb 07, 2008 12:49 pm Post subject: |
|
|
| Definitely not the best solution, but you can call NtShutdownSystem as well.
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
|
| Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Thu Feb 07, 2008 3:32 pm Post subject: |
|
|
Or you could create a task for Windows, that calls shutdown.exe.
o_o
_________________
|
|
| Back to top |
|
 |
Noz3001 I'm a spammer
Reputation: 26
Joined: 29 May 2006 Posts: 6220 Location: /dev/null
|
Posted: Thu Feb 07, 2008 5:02 pm Post subject: |
|
|
I thought ExitWindows just logged you off?
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Thu Feb 07, 2008 5:29 pm Post subject: |
|
|
If you use the extended version you have the ability to control what level of "shutdown" it will do:
| Code: | BOOL WINAPI ExitWindowsEx(
__in UINT uFlags,
__in DWORD dwReason
); |
uFlags can be:
Logoff / Shutdown+PowerOff / Reboot / Reboot+RestartApps / Shutdown
Check the descriptions on the link I gave above.
_________________
- Retired. |
|
| Back to top |
|
 |
|