Click here to Skip to main content
Click here to Skip to main content

Parental Control App

, 12 Oct 2012
Rate this:
Please Sign up or sign in to vote.
Parental control app.

Introduction

This was my latest project in VB.NET. This article describes how to make an application for parental control, which has a feature to stop and kill browser applications like Mozilla, Chrome, Internet Explorer, Flock etc when user navigates to sites with sexual content. Basically this software will detect strings in active windows so if the caption of the main windows of the process contains adult content it will automatically kill process all browser applications. Not only that when the user executes some application that the caption of main window contains adult content it will give an annoying warning message.

Declare Function

First, we declare a function like below:

Private Declare Function GetForegroundWindow Lib "user32.dll" () As IntPtr
Private Declare Function GetWindowThreadProcessId Lib _
        "user32.dll" (ByVal hwnd As IntPtr, ByRef lpdwProcessID As Integer) As Integer
Private Declare Function GetWindowText Lib "user32.dll" Alias _
        "GetWindowTextA" (ByVal hWnd As IntPtr, _
        ByVal WinTitle As String, ByVal MaxLength As Integer) As Integer
Private Declare Function GetWindowTextLength Lib "user32.dll" Alias _
        "GetWindowTextLengthA" (ByVal hwnd As IntPtr) As Integer

Add this code to the tick event, and it will make textbox3.text contain the caption of the main windows of the process.

Private Sub Timer1_Tick(ByVal sender As System.Object, _
            ByVal e As System.EventArgs) Handles Timer1.Tick
    Try
        '—– Get the Handle to the Current Forground Window —–
        Dim hWnd As IntPtr = GetForegroundWindow()
        If hWnd = IntPtr.Zero Then Exit Sub

        '—– Find the Length of the Window’s Title —–
        Dim TitleLength As Integer
        TitleLength = GetWindowTextLength(hWnd)

        '—– Find the Window’s Title —–
        Dim WindowTitle As String = StrDup(TitleLength + 1, "*")
        GetWindowText(hWnd, WindowTitle, TitleLength + 1)

        '—– Find the PID of the Application that Owns the Window —–
        Dim pid As Integer = 0
        GetWindowThreadProcessId(hWnd, pid)
        If pid = 0 Then Exit Sub

        '—– Get the actual PROCESS from the process ID —–
        Dim proc As Process = Process.GetProcessById(pid)
        If proc Is Nothing Then Exit Sub


        TextBox3.Text = proc.MainWindowTitle
        RepoveDuplicate()


    Catch

    End Try

End Sub

Then add this code to textbox3 in the TextChanged event. When textbox3 contains a sensitive string it will execute the killer method.

Private Sub TextBox3_TextChanged(ByVal sender As System.Object, _
            ByVal e As System.EventArgs) Handles TextBox3.TextChanged

    ListBox1.Items.Add(TextBox3.Text)
    If TextBox3.Text.Contains("sex") Then
        MessageBox.Show("Please do not open sexual site content!", _
               "Anti Porno Detector", MessageBoxButtons.OK, MessageBoxIcon.Information)
        killer()

    ElseIf TextBox3.Text.Contains("hardsextube") Then
        MessageBox.Show("Please do not open sexual site content!", _
               "Anti Porno Detector", MessageBoxButtons.OK, MessageBoxIcon.Information)
        killer()

    ElseIf TextBox3.Text.Contains("tube8") Then
        MessageBox.Show("Please do not open sexual site content!", _
            "Anti Porno Detector", MessageBoxButtons.OK, MessageBoxIcon.Information)
        killer()

You can see more code in the zip files. And the below code is the code for the killer method.

Public Function killprocess(ByVal processname As String)

    'Get list of all running processes
    Dim proc() As Process = Process.GetProcesses

    'Loop through all processes
    For i As Integer = 0 To proc.GetUpperBound(0)
        If proc(i).ProcessName = processname Then
            proc(i).Kill()
        End If
    Next

End Function

Public Sub killer()
    killprocess("firefox")
    killprocess("chrome")
    killprocess("iexplore")
    killprocess("opera")
    killprocess("safari")
    killprocess("flock")
End Sub

You can see more in the zip and improve this software with added features. Hopefully it will benefit all.

License

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

About the Author

Gun Gun Febrianza
CEO Technology Pandawa
Indonesia Indonesia
No Biography provided
Follow on   Twitter

Comments and Discussions

 
GeneralMy vote of 5 Pinmemberhazeleekaizera15-Oct-12 16:46 
GeneralRe: My vote of 5 PinmemberGun Gun Febrianza15-Oct-12 23:06 
GeneralMy vote of 5 PinmemberCarsten V2.012-Oct-12 6:03 
GeneralRe: My vote of 5 [modified] PinmemberGun Gun Febrianza12-Oct-12 6:06 

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

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

| Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 12 Oct 2012
Article Copyright 2012 by Gun Gun Febrianza
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid