comet
Welcome to LanDen Labs
Source Code, Tools, Developer Notes and Performance Metrics

landenlabs.com

[ To Main Page ]


Parental Time Limit Program too keep children from using too much time on computer

lockdown

LockDown v1.2

This C# Application is a combination Windows Service and User Interface designed to manage how long a user can use a windows account. The administrator can set daily time limits and the program will monitor the user's time logged in and when they approach the time limit, they are given a warning and eventually forced to log off. The program tries to ignore idle time, so if a user walks away from the computer it does not count against them.

If the user logs back in, they are immediately given the warning and logged off again.

If they are clever and start Task Manager and kill LockDown it automatically restarts.

There is no guarrenty this program is bullet proof and I know of ways to get around it but the source code is available for others to use and enhance. Please give me credit if you use the code.

Program Structure

LockDown's primary component is run as a window's service. This has several advanatages:
  1. It is automatically started and available in every user account
  2. It gets automatically restarted if killed or if it crashes
  3. It has administrative priviledges and is able to force an account to log off.
The only downsideds to a Window's Service is they don't have access to the screen. To allow LockDown to run as both a Service and present a User Interface I run two copies of LockDown. The first copy runs as a Window's Service and monitors the user log in time. The 2nd copy is run in the user's account and present the current time usage status dialog in the lower right and if an authorized administrator, can open the Configuration and History dialogs.

Since the two copies of LockDown are run as different users on the same system, they communicate with each other via a shared memory region. The memory is used to send messages back and forth.

Main Program Components

Module Description
LockDownBg.cs Runs in background as window's service
LockDownFg.cs Runs in foreground as User Interface.

A good chunk of LockDown is various code fragments I found on the web or created to support these functions:

Module Description
User32DLL List of User Accounts
SharedMemory Create shared memory
IntSvcInstaller, SvcInstaller Install program as a Window's Service
DataMgr Read/write to Registry
RunsAs, SensAdviser Manage priviledges and access controls
WinExitWindows Force account to exit.
WinIdel Measure Idle time.

Command Line Options:

When you start LockDown for the very first time, you need to install it as a window's service. LockDown can do this automatically if you run it with the -install switch.
install

Here is a list of all the available command line options:

-about Tell everyone about the author and program version
-install Install LockDown as a Windows Service
-uninstall Uninstall LockDown Windows Service.


Status Dialog

After you install LockDown it will start a small time status dialog in the lower right corner. The dialog is partially transparent until you give it focus.
status1
The dialog and the icon have a context menu. The full menu is available to the administrator uesrs. Via the menu you can open the configuration dialog.
menu

Configuration Dialog

The configuration dialog allows you to set the administrator accounts and to set the user account time limits.

config

History Dialog

In addition to the user time configuration, you can open a History dialog to see the elapsed time per user.
history
The history dialog has options to export the values as ".csv" it you want to use Excel to generate graphs, etc.

Alarm Dialog

Lastly there is a built-in alarm clock. This dialog is busy and has several options to set the time or period and what kind of event to fire when the alarm target is reached, such as play a 'wav' sound file, display and image or animated GIF and/or run a program.

alarm