Solved

After an idle period, shutdown a windows machine as NT service.

Posted on 2003-11-24
6
234 Views
Last Modified: 2010-04-05
Hi! I´m trying to make an application that can do shutdown a machine running windows 2000 or xp, after a certain idle period of time. But i´de like that the application running as NT Service. The goal is running without having to enter on session time. Can it be possible? And how?
Thanks All
0
Comment
Question by:frizze
  • 3
6 Comments
 
LVL 5

Accepted Solution

by:
snehanshu earned 63 total points
ID: 9815968
frizze,
  I am working on a utility that monitoris the Idle time of the PC. The way I am doing it is to hook to keyboard and mouse events to find out how long the system was idle (using a service). I check it periodically (using a timer) and save the idle time.
  If that helps, read on...
  I have asked a few questions at EE for doing that and you could have a look at those. There are two ways you could do it:
1) Using Journal hooks
2) Using individual Keyboard/mouse hooks
  When I asked here, I was recommended that for longer periods of time, non-journal hooks are better. But perhaps journal hooks are simple. So, you could decide on what you want.

Links:
  My journal hook service code is posted in this Q:
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20794138.html

This is where I got the code for a DLL that creates Kbd hooks (non-journal):
http://www.swissdelphicenter.ch/torry/showcode.php?id=1722

This is for using the DLL described above from the service:
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20750612.html

And this is the debate of what to use journal or other hook:
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20750833.html

  I am asking you to chase a lot of links, but doing that gave me a better understanding of what I wanted. hope it works the same way for you too.
  Cheers,
...Snehanshu
0
 
LVL 7

Assisted Solution

by:sftweng
sftweng earned 62 total points
ID: 9832770
An easy way to detect that a machine is idle is described in:
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20810017.html

Do you need assistance with running as a service and forcing shutdown?
0
 
LVL 5

Expert Comment

by:snehanshu
ID: 9849095
frizze,
  I have posted some code at
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20810017.html
  It shows how you could use a timer and Journal hook to perform some action on inactivity.
  The code is not for a service, but you can easily make a service out of it. Do let me know if you need any help with converting the code there into a service.
  Cheers!
...Shu
0
 
LVL 5

Expert Comment

by:snehanshu
ID: 9849110
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
URL for downloading Google Chrome for Win XP 2 158
How to debug For loops? 3 49
update joined tables 2 47
How to save the image in the .cds File ClientDataSet? 1 13
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

823 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question