Пример #1
0
 private void iTalk_Button_11_Click(object sender, EventArgs e)
 {
     if (!muic.Checked && !wlogs.Checked && !rfile.Checked && !compstore.Checked && !fixlnk.Checked && !mpoint.Checked && !trac.Checked && !rapp.Checked && !rstart.Checked && !useras.Checked && !rebin.Checked && !pref.Checked)
     {
         notifyIcon1.ShowBalloonTip(100, "Optimised", "Nu uita sa selectezi ce doresti sa stergi.", ToolTipIcon.Info);
     }
     else
     {
         if (fixlnk.Checked == true)
         {
             ResolveLnkDesktop();
         }
         if (Optimised_Manual.IsBusy)
         {
             notifyIcon1.ShowBalloonTip(1000, "Optimised", "In acest moment se efectueaza optimizarea.", ToolTipIcon.Info);
         }
         else
         {
             listBox1.Items.Clear();
             iTalk_GroupBox1.Text = "Last Log Optimised";
             Optimised_Manual.RunWorkerAsync();
         }
     }
 }
Пример #2
0
 private void Optimised_Manual_DoWork(object sender, DoWorkEventArgs e)
 {
     ListBox.CheckForIllegalCrossThreadCalls = false;
     iTalk.iTalk_GroupBox.CheckForIllegalCrossThreadCalls = false;
     notifyIcon1.ShowBalloonTip(1000, "Optimised", "Optimizarea a pornit.", ToolTipIcon.Info); //Trimite messajul primit de la actiunea trimisa din Cloud.
     iTalk_GroupBox1.Text = "Last Log Optimised - " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:s"); Refresh();
     if (muic.Checked == true)
     {
         try
         {
             regKey = Registry.CurrentUser.OpenSubKey(@"Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache", true);
             foreach (string value in regKey.GetValueNames())
             {
                 regKey.DeleteValue(value, true);
                 listBox1.Items.Add("MUI Cache: " + value);
             }
             regKey.Close();
         }
         catch
         {
         }
     }
     for (int i = 0; i <= 10; i++)
     {
         Optimised_Manual.ReportProgress(i);
         Thread.Sleep(100);
     }
     if (pref.Checked == true)
     {
         try
         {
             Array.ForEach(Directory.GetFiles(windows + @"Windows\Prefetch\", "*.pf"),
                           delegate(string path)
             {
                 File.Delete(path);
                 if (!File.Exists(path))
                 {
                     listBox1.Items.Add("Prefetch: " + path);
                 }
             });
         }
         catch { }//Delete Prefetch
     }
     for (int j = 10; j <= 20; j++)
     {
         Optimised_Manual.ReportProgress(j);
         Thread.Sleep(100);
     }
     if (rapp.Checked == true)
     {
         try
         {
             RegistryKey regKeyAppRoot = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Search\RecentApps", true);
             foreach (string value in regKeyAppRoot.GetSubKeyNames())
             {
                 regKeyAppRoot.DeleteSubKeyTree(value, true);
                 listBox1.Items.Add("Recent Apps: " + value);
             }
             regKeyAppRoot.Close();
         }
         catch { }//Delete Regedit
     }
     for (int j = 20; j <= 30; j++)
     {
         Optimised_Manual.ReportProgress(j);
         Thread.Sleep(100);
     }
     if (temp.Checked == true)
     {
         string pat = Path.GetTempPath();
         System.IO.DirectoryInfo di = new DirectoryInfo(pat.ToString());
         foreach (FileInfo file in di.GetFiles())
         {
             try
             {
                 file.Delete();
                 if (!File.Exists(file.FullName))
                 {
                     listBox1.Items.Add("Temp File: " + file.FullName);
                 }
             }
             catch { }
         }
         foreach (DirectoryInfo dir in di.GetDirectories())
         {
             try
             {
                 dir.Delete(true);
                 if (!Directory.Exists(dir.FullName))
                 {
                     listBox1.Items.Add("Temp Dir: " + dir.FullName);
                 }
             }
             catch { }
         }
     }
     for (int j = 30; j <= 40; j++)
     {
         Optimised_Manual.ReportProgress(j);
         Thread.Sleep(100);
     }
     if (trac.Checked == true)
     {
         try
         {
             RegistryKey regKeyAppRoot = Registry.LocalMachine.OpenSubKey(@"Software\WOW6432Node\Microsoft\Tracing", true);
             foreach (string value in regKeyAppRoot.GetSubKeyNames())
             {
                 regKeyAppRoot.DeleteSubKeyTree(value, true);
                 listBox1.Items.Add("Tracing: " + value);
             }
             regKeyAppRoot.Close();
         }
         catch
         { }//Delete Regedit
     }
     for (int j = 40; j <= 50; j++)
     {
         Optimised_Manual.ReportProgress(j);
         Thread.Sleep(100);
     }
     if (rebin.Checked == true)
     {
         try { uint result = SHEmptyRecycleBin(IntPtr.Zero, null, RecycleFlags.SHERB_NOCONFIRMATION); } catch { }
     }
     for (int j = 50; j <= 60; j++)
     {
         Optimised_Manual.ReportProgress(j);
         Thread.Sleep(100);
     }
     if (rfile.Checked == true)
     {
         String recent = Environment.ExpandEnvironmentVariables("%APPDATA%") + @"\Microsoft\Windows\Recente";
         try
         {
             Array.ForEach(Directory.GetFiles(recent, "*.*"),
                           delegate(string path)
             {
                 File.Delete(path);
                 if (!File.Exists(path))
                 {
                     listBox1.Items.Add("Recent Files: " + path);
                 }
             });
         }
         catch { }//Delete Recent files
         try { SHAddToRecentDocs(ShellAddToRecentDocsFlags.Pidl, (IntPtr)(0)); } catch { }
     }
     for (int j = 60; j <= 70; j++)
     {
         Optimised_Manual.ReportProgress(j);
         Thread.Sleep(100);
     }
     if (wlogs.Checked == true)
     {
         foreach (var eventLog in EventLog.GetEventLogs())
         {
             try
             {
                 eventLog.Clear();
                 eventLog.Dispose();
             }
             catch { }
         }
     }
     if (mpoint.Checked == true)
     {
         try
         {
             RegistryKey regKeyAppRoot = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2", true);
             foreach (string values in regKeyAppRoot.GetSubKeyNames())
             {
                 regKeyAppRoot.DeleteSubKeyTree(values, true);
                 listBox1.Items.Add("MountPoints: " + values);
             }
         }
         catch { }//Delete Regedit
     }
     for (int j = 70; j <= 80; j++)
     {
         Optimised_Manual.ReportProgress(j);
         Thread.Sleep(100);
     }
     if (rstart.Checked == true)
     {
         try
         {
             regKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
             foreach (string value in regKey.GetValueNames())
             {
                 regKey.DeleteValue(value, true);
                 listBox1.Items.Add("Run At Startup: " + value);
             }
             regKey.Close();
         }
         catch
         {
         }
     }
     for (int j = 80; j <= 90; j++)
     {
         Optimised_Manual.ReportProgress(j);
         Thread.Sleep(100);
     }
     if (useras.Checked == true)
     {
         try
         {
             regKey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\UserAssist", true);
             foreach (string value in regKey.GetSubKeyNames())
             {
                 regKey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\" + value.ToString() + @"\Count", true);
                 foreach (string cont in regKey.GetValueNames())
                 {
                     regKey.DeleteValue(cont, true);
                     listBox1.Items.Add("UserAssist: " + Rot13.Transform(cont));
                 }
             }
             regKey.Close();
         }
         catch
         {
         }
     }
     for (int j = 90; j <= 100; j++)
     {
         Optimised_Manual.ReportProgress(j);
         Thread.Sleep(100);
     }
     if (compstore.Checked == true)
     {
         try
         {
             RegistryKey regKeyAppRoot = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Compatibility Assistant\Store", true);
             foreach (string values in regKeyAppRoot.GetValueNames())
             {
                 regKeyAppRoot.DeleteValue(values, true);
                 listBox1.Items.Add("Compatibility Store: " + values);
             }
         }
         catch { }//Delete Regedit
     }
     notifyIcon1.ShowBalloonTip(1000, "Optimised", "Optimizarea a fost efectuata.", ToolTipIcon.Info); //Trimite messajul primit de la actiunea trimisa din Cloud se termina.
 }