This program I'm working on has a couple of main interests points I'm aiming at:
1) Monitor and implement HOSTS file
( this is a WINDOWS NT based file and has the ability to block and keep traffic from going to/from URLs that are deemed not wanted for work computers or harmful to the system )
2) Monitor process list of windows and keep unwanted programs from running
( this is the tricky part of the program that i am inquiring help about)
I have so far a working application that can sit dormant in the system tray consuming as little CPU/Memory power as possible and at this point have gotten the app to be able to update the HOSTS file and kill processes in a black list that we specified ( on initial running of app and the program has to be open already )
What i was inquiring about is if anyone knows a way for a real-time tracking of the process list ( or another method of doing what i wish to achieve ) to where when a process is freshly listed in the process list the app will auto query it against the blacklist and either 1) do nothing or 2) kill the process if it is not allowed.
I will say i am FRESH to VB coding but i do have ample ability to get around PHP ( which i know has nothing to do with VB but gives me the ability to decipher code blocks to a extent of learning what it does ) and ANY help or where to read about what I am trying to do someplace would be GREATLY appreciated.
Below is what i have for the blacklist so far but this only working when the program is ran and only works on programs that are already open
Private Sub ProgramWatchList() Dim conn As New SqlCeConnection Dim SilentConnString As String = My.Settings.WPIDMDataConnectionString Try conn = New SqlCeConnection(SilentConnString) Dim cmd As SqlCeCommand = conn.CreateCommand() Dim xI As Integer = 0 cmd.CommandText = "SELECT COUNT(*) FROM Proc_List" conn.Open() Dim rdr As SqlCeDataReader = Nothing xI = CInt(cmd.ExecuteScalar()) Dim ProgramName(xI) As String Dim ProgramEXE(xI) As String Dim i As Integer = 0 cmd.CommandText = "SELECT ProgName, ProgEXE FROM Proc_List" rdr = cmd.ExecuteReader(Commandbehavior.CloseConnection) While rdr.Read() ProgramName(i) = rdr.GetString(0) ProgramEXE(i) = rdr.GetString(1) i = i + 1 End While Dim p As System.Diagnostics.Process For Each p In System.Diagnostics.Process.GetProcesses() Dim ProcName As String Dim ProcID As Integer ProcName = p.ProcessName ProcID = p.Id If InStr(Join(ProgramName), ProcName) > 0 Then p.Kill() End If If InStr(Join(ProgramEXE), ProcName) > 0 Then p.Kill() End If Next Catch ex As SqlCeException MessageBox.Show(ex.Message) Finally conn.Close() End Try End Sub
This post has been edited by RPGonzo: 16 March 2009 - 09:58 AM