Click here to Skip to main content
15,884,177 members
Articles / Programming Languages / C#
Article

Simple Parental Control Service in C#

Rate me:
Please Sign up or sign in to vote.
3.67/5 (3 votes)
31 Mar 2008CPOL2 min read 42.6K   1.2K   24   5
Windows service in C# which allows to control computer's ON/OFF time: automatically turns computer OFF every day at the desired time

Introduction

This project helps to create your own parental control service in C#. The current version will shutdown Windows if an unauthorized user (your kid) tries to boot the family PC during blockout period, say from 11 pm to 7 am.

Background

My friend Alexander asked me if I can help him to control his kid's access to the family PC. I did some research on the Internet and found that there are many of those applications available but:

  1. You have to buy them
  2. They are too complicated for use and have too many options which I will never use

So, I decided to write my own application to help him. The idea was just to write a Windows service which will monitor the system clock and shut down the system if blockout time occurs. But an easy way for a kid to fix this is to change the system clock. This operation takes a little effort and could be done by any computer kid. So, our service has to fix the system clock whenever it's changed. To do that, we can use some Internet resources, say well known time saver tick.usno.navy.mil.

Using the Code

The project contains three main parts:

  1. Service Control Part ParentControl.cs, which checks the current system clock against the blockout period.
  2. Internet Time Synchronization Client NTPClient.cs (written by Valer BOCAN vbocan@dataman.ro).
  3. ExitWindows.cs which is just a C# wrapper for ExitWindowsEx API call (original C++ code sample could be found here).

If the service cannot obtain time from the time server, it will shut down the computer as well. By default, the blockout period starts at 11 pm and ends at 7 am. You can specify different numbers as two parameters at the service start time. In the DEBUG version (only!) this service will ask if you want to shut down your PC or not. To make it possible, you have to check the "Allow service to interact with desktop" box when starting the service.

To install the service, you use InstallUtil.exe from the .NET Framework or call it from the command line with argument -i:

ParentalControl -i 

To make the service self installable, I used a technique described in my other article (Windows Service which Kills Unwanted Windows).

Points of Interest

This project could be easily developed for different parental control services depending on what you need.

History

  • First version uploaded March 31st, 2008

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Intel Corp.
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Questionhow to uninstall it? Pin
Jack Xu, USA16-Mar-14 1:54
Jack Xu, USA16-Mar-14 1:54 
Generalparental control web filter Pin
rudychip16-Aug-09 3:03
rudychip16-Aug-09 3:03 
GeneralRe: parental control web filter Pin
Pascal Ganaye17-Jun-10 10:16
Pascal Ganaye17-Jun-10 10:16 
QuestionControl Computer Access Pin
ansar_ansar12-Dec-08 2:22
ansar_ansar12-Dec-08 2:22 
GeneralZip file link Pin
fwsouthern6-Apr-08 17:56
fwsouthern6-Apr-08 17:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.