views:

51

answers:

2

Can anyone point me to some C# samples for the Windows Parental Controls API. I want to add some functionality that will allow a user to set the duration their child can be logged on in a day. I want to do this as a F/OSS app so that others can benefit from this too.

Cheers.

A: 

An application like that already exists: LimitLogin.

Also you could use Limit User Logon Time (would be trivial in C#).

Parental Controls WMI Provider API + ManagementClass Class

Edit: To logout a user: ExitWindowsEx or commands (shutdown, PsShutdown, ...).

Jaroslav Jandek
Jaroslav. Thanks for providing some info. I looked at LimitLogin but that requires an AD connected machine. This is for a child's netbook that a non-tech user wants to get setup. Limit User Logon Time is only useful for setting up when the user can logon and not for setting a duration. For instance, they don't want their kid to use the machine for more than 1 hour a day. The ManagementClass Class doesn't seem to provide much use. The Parental Controls WMI Provider API does not provide the ability to set duration. It only allows you to set logon hours. Thanks for trying nonetheless.
AboutDev
Well, I do not see a problem there. You can programatically logout a user and with the presented articles make sure the user cannot login again.
Jaroslav Jandek
Yes you can logout a user programmatically. However, you still have to consider how to secure the app and data store. Also have to ensure that they don't just boot into safe mode and disable services etc. It's much easier to use existing processes that MS has developed and tie into them to add new functionality, much like what the Windows Live Child monitor or whatever its called do.I just wondered if anyone has worked with the API to know how to use it for adding duration.
AboutDev
AFAIK there is no such option, you can only specify such options when you use Active Directory. Also there are tools to disable safe mode, etc. You just have to work in tandem with other windows security services. Also you must limit access to disk and management for your children.
Jaroslav Jandek
I think the way to do it would be to become a 'provider'. This allows your own code to integrate into the Parental Controls through their API. The question I had was how I could do this through c#. Tying into their API would allow me to bypass having to do things like safemode and file access checks/hacks. At least I think this is the way to do it from what I have read (and there really isn't too much out there on this topic.)
AboutDev
A: 

It seems like there is no way to achieve this using the MS Windows SDK provided API and no c# samples to use as a reference. I tried this for Windows 7 and the only way to make this work is to set the blocked hours the first time someone logs in to the machine each day.

AboutDev