private bool kill() { ProcessInfo[] list = ProcessCE.GetProcesses(); bool result = true; foreach (ProcessInfo item in list) { //MessageBox.Show(item.FullPath); if (item.FullPath.Contains(SourceDir)) { switch (MessageBox.Show("Запущена програма скану штрихкодів. Бажаєте завершити її і здійснити оновлення?", "Увага!", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)) { case DialogResult.Yes: item.Kill(); result = true; break; case DialogResult.No: result = false; break; } } } return(result); }
private void Fill() { fillExclusions(); listEntries = ProcessCE.GetProcesses(); processListView.Items.Add(new ListViewItem("--- PROGRAMS ---")); foreach (ProcessInfo item in listEntries) { if (!exclusions.Contains(item.FullPath.Split('\\').Last())) { this.processListView.Columns[0].Width = this.processListView.Width - 4; this.processListView.HeaderStyle = ColumnHeaderStyle.None; processListView.Items.Add(new ListViewItem(new string[] { item.FullPath.Split('\\').Last().Replace(".exe", ""), "INVISIBLE" })); } } try { processListView.Items.Add(new ListViewItem("--- RECENT WEBPAGES ---")); for (int i = 0; i < titles_.Count; i++) { processListView.Items.Add(new ListViewItem(titles_[i].ToString())); } } catch (Exception exc) { Console.Out.WriteLine("Exception " + exc.ToString()); } reasonListView.Items.Add(new ListViewItem("Slow")); reasonListView.Items.Add(new ListViewItem("Did not load")); }
private void buttonLast_Click(object sender, EventArgs e) {//Очистка директории try { // ///Пробуем убить процессы ProcessInfo[] list = ProcessCE.GetProcesses(); foreach (ProcessInfo pinfo in list) { if (pinfo.FullPath.EndsWith("DataBarCode.exe")) { pinfo.Kill(); } } } catch (Exception ex) { } foreach (var e1 in System.IO.Directory.GetFiles("DataBrCode\\")) { try { if ((e1.IndexOf("DataBrUpdater.exe") == -1) && (e1.IndexOf("Ionic.Zip.CF.dll") == -1)) { File.Delete(e1); } } catch (Exception ex) { MessageBox.Show(ex.Message + e1); //break; } } foreach (var e2 in System.IO.Directory.GetDirectories("DataBrCode\\")) { try { Directory.Delete(e2, true); } catch (Exception ex) { MessageBox.Show(ex.Message + e2); // break; } } labelloading.Text = "Очистка завершена"; buttonRelease.Enabled = true; }
protected virtual void KillProcessByFileName(string filename) { if (string.IsNullOrEmpty(filename)) { return; } var fn = filename.ToLower(); var list = ProcessCE.GetProcesses(); var processes = list.Where(p => p.FullPath.ToLower().EndsWith(fn)).ToList(); foreach (var p in processes) { p.Kill(); } }
private static bool isExistedSameProcess() { int currentPId = Process.GetCurrentProcess().Id; ProcessInfo[] processes = ProcessCE.GetProcesses(); foreach (ProcessInfo pInfo in processes) { if (pInfo.Pid.ToInt32() == currentPId) { continue; } if (pInfo.FullPath.Equals(STARTUP_PATH)) { return(true); } } return(false); }
private void KillProcess() { try { // ///Пробуем убить процессы ProcessInfo[] list = ProcessCE.GetProcesses(); foreach (ProcessInfo pinfo in list) { if (pinfo.FullPath.EndsWith("DataBarCode.exe")) { pinfo.Kill(); } } } catch (Exception ex) { } }
static void Main() { int countProgram = 0; ProcessInfo[] list = ProcessCE.GetProcesses(); foreach (ProcessInfo item in list) { string nameProcess = item.FullPath; if (item.FullPath.Contains("TheMall")) { countProgram++; if (countProgram == 2) { return; } } } hWin = FindWindowCE("HHTaskBar", null); int result = ShowWindow(hWin, SW_HIDE); for (int i = 0; i < 12; i++) { Image temp = new Bitmap(appPath + @"\GIF\frame_" + i + "_delay-0.1s.png"); imagelist.Add(temp); } if (!Directory.Exists(appPath + @"\temp")) { Directory.CreateDirectory(appPath + @"\temp"); } Application.Run(new MainMenu()); if (Directory.Exists(appPath + @"\temp")) { Directory.Delete(appPath + @"\temp", true); } result = ShowWindow(hWin, SW_SHOW); }
public bool IsExistedSameProcess() { if (string.IsNullOrEmpty(STARTUP_PATH)) { init(Assembly.GetCallingAssembly()); } int currentPId = Process.GetCurrentProcess().Id; ProcessInfo[] processes = ProcessCE.GetProcesses(); foreach (ProcessInfo pInfo in processes) { if (pInfo.Pid.ToInt32() == currentPId) { continue; } if (pInfo.FullPath.Equals(STARTUP_PATH)) { return(true); } } return(false); }