-
January 19th, 2007, 11:37 AM
#1
App to turn of computer after some time
I was wondering if it's possible to write an application that turn's of your computer after an hour, for ex. If it is could someone give me some pointers on how I might go about doing that? Thanks a lot.
-
January 19th, 2007, 11:51 AM
#2
Re: App to turn of computer after some time
Hi,
1) How do I shut down the computer?
There´s a Win32 API function called InitiateSystemShutdown. Unfortunately you can´t just call it and expect Windows to shut down, you have to enable the SE_SHUTDOWN privilege. A complete example of how to to that can be found here: System shutdown dialog.
Another way to shut down a computer is to execute "shutdown -s -f".
2) How do I know when to shut down the computer?
Define a timestamp (maybe date) when the computer is to be shut down. Periodically check the system time against the timestamp and as soon as you passed shut down the computer as suggested in 1).
I think there are many free tools that accomplish that task for you, so you don´t have to program that on your own.
Hth,
Guido
- Guido
-
January 19th, 2007, 01:13 PM
#3
Re: App to turn of computer after some time
Thanks a lot. I think I'll use shutdown -s -f. Seem the most simple. Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|