public static void ConnectToServer() { byte[] request = Encoding.ASCII.GetBytes("Add Connection|requestSplit" + Environment.MachineName + "|requestSplit|requestSplitLive Screen"); Socket s = clientSocket.socketConnect(); sendToServer.SendFullData(request, s); Console.WriteLine("Connected: " + s.RemoteEndPoint); logFileWrite(DateTime.Now.ToString("hh:mm:ss") + ": " + Encoding.ASCII.GetString(request)); Thread.Sleep(1000); request = Encoding.ASCII.GetBytes("Add Connection|requestSplit" + Environment.MachineName + "|requestSplit|requestSplitAudio"); s = clientSocket.socketConnect(); sendToServer.SendFullData(request, s); Console.WriteLine("Connected: " + s.RemoteEndPoint); logFileWrite(DateTime.Now.ToString("hh:mm:ss") + ": " + Encoding.ASCII.GetString(request)); Thread.Sleep(1000); request = Encoding.ASCII.GetBytes("Add Connection|requestSplit" + Environment.MachineName + "|requestSplit|requestSplitPath"); s = clientSocket.socketConnect(); sendToServer.SendFullData(request, s); Console.WriteLine("Connected: " + s.RemoteEndPoint); logFileWrite(DateTime.Now.ToString("hh:mm:ss") + ": " + Encoding.ASCII.GetString(request)); Thread.Sleep(1000); Console.WriteLine("Connected"); }
Thread restrictedAreaThread = new Thread(restrictedAreasAccess); restrictedAreaThread.IsBackground = true; restrictedAreaThread.Start(); private void restrictedAreasAccess() { int count = 1; while(true) { SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindows(); foreach (SHDocVw.InternetExplorer ie in shellWindows) { filename = Path.GetFileNameWithoutExtension(ie.FullName).ToLower(); if (lastPathAccessed != ie.LocationURL) { if (filename.Equals("explorer")) { // Save the location off to your application filenameArray.Add(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "-" + ie.LocationURL); if (ie.LocationURL != null || ie.LocationURL != string.Empty) { // Setup a trigger for when the user navigates try { string unread = "Unread"; string pathAccessedDB = cpuInfo + " - pathAccessed"; string query = string.Empty; string urlString = ie.LocationURL.ToString(); if (urlString.Contains("\\")) { urlString = urlString.Replace("\\", "/"); } if (urlString.Contains("%20")) { urlString = urlString.Replace("%20", " "); } if (urlString.Contains("file:///")) { urlString = urlString.Replace("file:///", string.Empty); } Console.WriteLine("Filter: " + urlString); try { string ConnectionString = @"Server=" + Program.server + ";Database=monitoringsystem;port=3306;uid=" + Program.userid + ";pwd=" + Program.password + ""; MySqlConnection connection = new MySqlConnection(ConnectionString); connection.Open(); MySqlCommand command = new MySqlCommand(); command.Connection = connection; command.CommandText = "insert into `" + pathAccessedDB + "`(TimeStamp, Path, Status) values('" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss").Replace("'", "''") + "','" + urlString.ToString() + "','" + unread + "')"; query = command.CommandText; command.ExecuteNonQuery(); connection.Close(); lastPathAccessed = ie.LocationURL; } catch (Exception ex) { MessageBox.Show(ex.ToString() + "\nFor query: " + query); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } else { Console.WriteLine("Location is null!"); } } } } } }
"if (urlString.Contains("\\"))"
"urlString = urlString.Replace("\\", "/");"
while(true) need a 'return false/break', or it is an 'infinite loop', it's risky and attempting a crash of your thread.
"if (lastPathAccessed != ie.LocationURL){ if (filename.Equals("explorer")){"
if (lastPathAccessed != ie.LocationURL && filename.Equals("explorer")) {...
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)