Accueil > > > GESTIONNAIRE DE SERVICES, PROCESSUS, ET DRIVERS WINDOWS EN C#
GESTIONNAIRE DE SERVICES, PROCESSUS, ET DRIVERS WINDOWS EN C#
Information sur la source
Description
Le code sert à lister les drivers, les processus et les services Windows. Il est possible de gérer les services, terminer un processus, et ça ne liste que les drivers.
Source
- using System;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- using System.Data;
- using System.ServiceProcess;
- using System.Web;
- using System.Diagnostics;
- using System.Threading;
- using System.IO;
-
-
- namespace My_PCO
- {
- /// <summary>
- /// Ce Programme fait le listing des services, drivers et processus Windows.
- /// Il y a entre autres la possibilité de pouvoir influer sur certaines options
- /// (Arret, Démarrage, Pause, Redemarrage pour les services),
- /// (Terminer, Nouveau pour les processus)
- /// et un Refresh pour les drivers.
- /// </summary>
- public class Form1 : System.Windows.Forms.Form
- {
- private System.Windows.Forms.MenuItem InterrogationItem;
- private System.Windows.Forms.MenuItem AboutProjectItem;
- private System.Windows.Forms.MainMenu BarreDeMenu;
- private System.Windows.Forms.TabPage tabPage1;
- private System.Windows.Forms.TabControl tabOnglet;
- private System.Windows.Forms.MenuItem menuFichier;
- private System.Windows.Forms.MenuItem ExecuteItem;
- private System.Windows.Forms.TabPage tabPage2;
- private System.Windows.Forms.ListView listeProcessus;
- private System.Windows.Forms.TabPage tabPage3;
- private System.Windows.Forms.ListView listeServices;
- private System.Windows.Forms.ListView listeDrivers;
- private System.Windows.Forms.ColumnHeader columnNomServices;
- private System.Windows.Forms.ColumnHeader columnEtat;
- private System.Windows.Forms.ColumnHeader columnNomConvivial;
- private System.Windows.Forms.ColumnHeader columnNomDriver;
- private System.Windows.Forms.ColumnHeader columnNomDriverConvivial;
- private System.Windows.Forms.ColumnHeader columnEtatDriver;
- private System.Windows.Forms.ColumnHeader columnNomProcessus;
- private System.Windows.Forms.Button BtnCloseProcess;
- private System.Windows.Forms.Button btnStartService;
- private System.Windows.Forms.Button BtnPauseService;
- private System.Windows.Forms.Button BtnRestartService;
- private System.Windows.Forms.Button BtnStopService;
- private System.Windows.Forms.Button BtnRefreshProcess;
- private System.Windows.Forms.Button BtnRefreshServices;
- private System.Windows.Forms.Button BtnRefreshDrivers;
- private System.Windows.Forms.ColumnHeader columnId;
- private System.Windows.Forms.ColumnHeader columnMemoire;
- private System.Windows.Forms.PictureBox pictureBox1;
- private System.Windows.Forms.MenuItem menuHelp;
- private System.Windows.Forms.MenuItem menuExit;
- /// <summary>
- /// Variable nécessaire au concepteur.
- /// </summary>
- private System.ComponentModel.Container components = null;
-
- //Fonction permettant d'obtenir la liste de tous les processus
- //et de les afficher dans une listView listeProcessus.
- protected void AvoirProcessus()
- {
- try
- {
- //Variables dans lesquelles nous récupèrerons qques données des processus
- string Nom_Processus, number_id, process_memory;
- listeProcessus.Items.Clear();
-
- foreach(Process myProcess in Process.GetProcesses())
- {
- Nom_Processus=myProcess.ProcessName; //retourne le nom des processus
- number_id=myProcess.Id.ToString(); //leur id
- process_memory=myProcess.NonpagedSystemMemorySize.ToString()+" ko"; // leur mémoire paginée
- listeProcessus.Items.Add(new ListViewItem(new string[]{Nom_Processus, number_id, process_memory}));
- }
- }
- catch
- {
- MessageBox.Show("Impossible de lister les processus");
- }
- }
-
-
- //Fonction permettant d'obtenir la liste de tous les Services
- //et de les afficher dans une listView listeServices
- protected void AvoirServices()
- {
- try
- {
- string Nom_Service, Nom_Complet, Etat="";
- listeServices.Items.Clear();
-
- foreach (ServiceController monservice in ServiceController.GetServices())
- {
- Nom_Service=monservice.ServiceName;
- Nom_Complet=monservice.DisplayName;
-
- if (monservice.Status==ServiceControllerStatus.Stopped)
- Etat="Arrêté";
- if (monservice.Status==ServiceControllerStatus.Running)
- Etat="Démarré";
- if (monservice.Status==ServiceControllerStatus.Paused)
- Etat="En pause";
-
- listeServices.Items.Add(new ListViewItem(new string[]{Nom_Service, Nom_Complet, Etat}));
- }
- }
- catch
- {
- MessageBox.Show("Impossible de lister les services");
- }
-
- }
-
- //Fonction faisant la liste de tous les Drivers
- protected void AvoirDrivers()
- {
- try
- {
-
- string Nom_Drivers,Nom_Complet, Etat="";
- listeDrivers.Items.Clear();
- foreach (ServiceController mondriver in ServiceController.GetDevices())
- {
- Nom_Drivers=mondriver.ServiceName;
- Nom_Complet=mondriver.DisplayName;
-
- if (mondriver.Status==ServiceControllerStatus.Stopped)
- Etat="Arrêté";
- if (mondriver.Status==ServiceControllerStatus.Running)
- Etat="Démarré";
- if (mondriver.Status==ServiceControllerStatus.Paused)
- Etat="En pause";
-
- listeDrivers.Items.Add(new ListViewItem(new string[]{Nom_Drivers, Nom_Complet, Etat}));
- }
- }
- catch
- {
- MessageBox.Show("Impossible de lister les drivers");
- }
- }
-
- public Form1()
- {
- //
- // Requis pour la prise en charge du Concepteur Windows Forms
- //
-
- // Nous initialisons nos différents affichages, Services, Drivers et Processus
- InitializeComponent();
- AvoirServices();
- AvoirDrivers();
- AvoirProcessus();
- //
- // TODO : ajoutez le code du constructeur après l'appel à InitializeComponent
- //
- }
-
- /// <summary>
- /// Nettoyage des ressources utilisées.
- /// </summary>
- protected override void Dispose( bool disposing )
- {
- if( disposing )
- {
- if (components != null)
- {
- components.Dispose();
- }
- }
- base.Dispose( disposing );
- }
-
- #region Windows Form Designer generated code
- /// <summary>
- /// Méthode requise pour la prise en charge du concepteur - ne modifiez pas
- /// le contenu de cette méthode avec l'éditeur de code.
- /// </summary>
- private void InitializeComponent()
- {
- System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
- this.BarreDeMenu = new System.Windows.Forms.MainMenu();
- this.menuFichier = new System.Windows.Forms.MenuItem();
- this.ExecuteItem = new System.Windows.Forms.MenuItem();
- this.menuExit = new System.Windows.Forms.MenuItem();
- this.InterrogationItem = new System.Windows.Forms.MenuItem();
- this.AboutProjectItem = new System.Windows.Forms.MenuItem();
- this.menuHelp = new System.Windows.Forms.MenuItem();
- this.tabOnglet = new System.Windows.Forms.TabControl();
- this.tabPage1 = new System.Windows.Forms.TabPage();
- this.BtnRefreshProcess = new System.Windows.Forms.Button();
- this.BtnCloseProcess = new System.Windows.Forms.Button();
- this.listeProcessus = new System.Windows.Forms.ListView();
- this.columnNomProcessus = new System.Windows.Forms.ColumnHeader();
- this.columnId = new System.Windows.Forms.ColumnHeader();
- this.columnMemoire = new System.Windows.Forms.ColumnHeader();
- this.tabPage3 = new System.Windows.Forms.TabPage();
- this.BtnRefreshDrivers = new System.Windows.Forms.Button();
- this.listeDrivers = new System.Windows.Forms.ListView();
- this.columnNomDriver = new System.Windows.Forms.ColumnHeader();
- this.columnNomDriverConvivial = new System.Windows.Forms.ColumnHeader();
- this.columnEtatDriver = new System.Windows.Forms.ColumnHeader();
- this.tabPage2 = new System.Windows.Forms.TabPage();
- this.BtnRefreshServices = new System.Windows.Forms.Button();
- this.BtnStopService = new System.Windows.Forms.Button();
- this.BtnRestartService = new System.Windows.Forms.Button();
- this.BtnPauseService = new System.Windows.Forms.Button();
- this.btnStartService = new System.Windows.Forms.Button();
- this.listeServices = new System.Windows.Forms.ListView();
- this.columnNomServices = new System.Windows.Forms.ColumnHeader();
- this.columnNomConvivial = new System.Windows.Forms.ColumnHeader();
- this.columnEtat = new System.Windows.Forms.ColumnHeader();
- this.pictureBox1 = new System.Windows.Forms.PictureBox();
- this.tabOnglet.SuspendLayout();
- this.tabPage1.SuspendLayout();
- this.tabPage3.SuspendLayout();
- this.tabPage2.SuspendLayout();
- this.SuspendLayout();
- //
- // BarreDeMenu
- //
- this.BarreDeMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
- this.menuFichier,
- this.InterrogationItem});
- //
- // menuFichier
- //
- this.menuFichier.Index = 0;
- this.menuFichier.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
- this.ExecuteItem,
- this.menuExit});
- this.menuFichier.Text = "Fichier";
- //
- // ExecuteItem
- //
- this.ExecuteItem.Index = 0;
- this.ExecuteItem.Text = "Executer";
- this.ExecuteItem.Click += new System.EventHandler(this.ExecuteItem_Click);
- //
- // menuExit
- //
- this.menuExit.Index = 1;
- this.menuExit.Text = "Exit";
- this.menuExit.Click += new System.EventHandler(this.menuExit_Click);
- //
- // InterrogationItem
- //
- this.InterrogationItem.Index = 1;
- this.InterrogationItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
- this.AboutProjectItem,
- this.menuHelp});
- this.InterrogationItem.Text = "?";
- //
- // AboutProjectItem
- //
- this.AboutProjectItem.Index = 0;
- this.AboutProjectItem.Text = "A propos!";
- this.AboutProjectItem.Click += new System.EventHandler(this.AboutProjectItem_Click);
- //
- // menuHelp
- //
- this.menuHelp.Index = 1;
- this.menuHelp.Text = "Help!!";
- this.menuHelp.Click += new System.EventHandler(this.menuHelp_Click);
- //
- // tabOnglet
- //
- this.tabOnglet.Controls.AddRange(new System.Windows.Forms.Control[] {
- this.tabPage1,
- this.tabPage3,
- this.tabPage2});
- this.tabOnglet.Dock = System.Windows.Forms.DockStyle.Bottom;
- this.tabOnglet.Location = new System.Drawing.Point(0, 89);
- this.tabOnglet.Name = "tabOnglet";
- this.tabOnglet.SelectedIndex = 0;
- this.tabOnglet.Size = new System.Drawing.Size(512, 320);
- this.tabOnglet.TabIndex = 0;
- //
- // tabPage1
- //
- this.tabPage1.Controls.AddRange(new System.Windows.Forms.Control[] {
- this.BtnRefreshProcess,
- this.BtnCloseProcess,
- this.listeProcessus});
- this.tabPage1.Location = new System.Drawing.Point(4, 22);
- this.tabPage1.Name = "tabPage1";
- this.tabPage1.Size = new System.Drawing.Size(504, 294);
- this.tabPage1.TabIndex = 0;
- this.tabPage1.Text = "Processus";
- //
- // BtnRefreshProcess
- //
- this.BtnRefreshProcess.BackColor = System.Drawing.SystemColors.ControlLight;
- this.BtnRefreshProcess.Location = new System.Drawing.Point(400, 260);
- this.BtnRefreshProcess.Name = "BtnRefreshProcess";
- this.BtnRefreshProcess.TabIndex = 3;
- this.BtnRefreshProcess.Text = "Refresh";
- this.BtnRefreshProcess.Click += new System.EventHandler(this.BtnRefreshProcess_Click);
- //
- // BtnCloseProcess
- //
- this.BtnCloseProcess.BackColor = System.Drawing.SystemColors.ControlLight;
- this.BtnCloseProcess.Location = new System.Drawing.Point(372, 56);
- this.BtnCloseProcess.Name = "BtnCloseProcess";
- this.BtnCloseProcess.Size = new System.Drawing.Size(128, 23);
- this.BtnCloseProcess.TabIndex = 2;
- this.BtnCloseProcess.Text = "Terminer le Processus";
- this.BtnCloseProcess.Click += new System.EventHandler(this.BtnCloseProcess_Click);
- //
- // listeProcessus
- //
- this.listeProcessus.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
- this.columnNomProcessus,
- this.columnId,
- this.columnMemoire});
- this.listeProcessus.Location = new System.Drawing.Point(12, 32);
- this.listeProcessus.Name = "listeProcessus";
- this.listeProcessus.Size = new System.Drawing.Size(350, 250);
- this.listeProcessus.TabIndex = 0;
- this.listeProcessus.View = System.Windows.Forms.View.Details;
- //
- // columnNomProcessus
- //
- this.columnNomProcessus.Text = "Nom Processus";
- this.columnNomProcessus.Width = 90;
- //
- // columnId
- //
- this.columnId.Text = "Id";
- //
- // columnMemoire
- //
- this.columnMemoire.Text = "Memoire";
- //
- // tabPage3
- //
- this.tabPage3.Controls.AddRange(new System.Windows.Forms.Control[] {
- this.BtnRefreshDrivers,
- this.listeDrivers});
- this.tabPage3.Location = new System.Drawing.Point(4, 22);
- this.tabPage3.Name = "tabPage3";
- this.tabPage3.Size = new System.Drawing.Size(504, 294);
- this.tabPage3.TabIndex = 2;
- this.tabPage3.Text = "Drivers";
- //
- // BtnRefreshDrivers
- //
- this.BtnRefreshDrivers.BackColor = System.Drawing.SystemColors.ControlLight;
- this.BtnRefreshDrivers.Location = new System.Drawing.Point(400, 260);
- this.BtnRefreshDrivers.Name = "BtnRefreshDrivers";
- this.BtnRefreshDrivers.TabIndex = 1;
- this.BtnRefreshDrivers.Text = "Refresh";
- this.BtnRefreshDrivers.Click += new System.EventHandler(this.BtnRefreshDrivers_Click);
- //
- // listeDrivers
- //
- this.listeDrivers.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
- this.columnNomDriver,
- this.columnNomDriverConvivial,
- this.columnEtatDriver});
- this.listeDrivers.Location = new System.Drawing.Point(12, 32);
- this.listeDrivers.Name = "listeDrivers";
- this.listeDrivers.Size = new System.Drawing.Size(350, 250);
- this.listeDrivers.TabIndex = 0;
- this.listeDrivers.View = System.Windows.Forms.View.Details;
- //
- // columnNomDriver
- //
- this.columnNomDriver.Text = "Nom du Driver";
- this.columnNomDriver.Width = 90;
- //
- // columnNomDriverConvivial
- //
- this.columnNomDriverConvivial.Text = "Nom Détaillé";
- this.columnNomDriverConvivial.Width = 90;
- //
- // columnEtatDriver
- //
- this.columnEtatDriver.Text = "Etat";
- //
- // tabPage2
- //
- this.tabPage2.Controls.AddRange(new System.Windows.Forms.Control[] {
- this.BtnRefreshServices,
- this.BtnStopService,
- this.BtnRestartService,
- this.BtnPauseService,
- this.btnStartService,
- this.listeServices});
- this.tabPage2.Location = new System.Drawing.Point(4, 22);
- this.tabPage2.Name = "tabPage2";
- this.tabPage2.Size = new System.Drawing.Size(504, 294);
- this.tabPage2.TabIndex = 1;
- this.tabPage2.Text = "Services";
- //
- // BtnRefreshServices
- //
- this.BtnRefreshServices.BackColor = System.Drawing.SystemColors.ControlLight;
- this.BtnRefreshServices.Location = new System.Drawing.Point(400, 260);
- this.BtnRefreshServices.Name = "BtnRefreshServices";
- this.BtnRefreshServices.TabIndex = 5;
- this.BtnRefreshServices.Text = "Refresh";
- this.BtnRefreshServices.Click += new System.EventHandler(this.BtnRefreshServices_Click);
- //
- // BtnStopService
- //
- this.BtnStopService.BackColor = System.Drawing.SystemColors.ControlLight;
- this.BtnStopService.Location = new System.Drawing.Point(404, 200);
- this.BtnStopService.Name = "BtnStopService";
- this.BtnStopService.Size = new System.Drawing.Size(64, 23);
- this.BtnStopService.TabIndex = 4;
- this.BtnStopService.Text = "Arreter";
- this.BtnStopService.Click += new System.EventHandler(this.BtnStopService_Click);
- //
- // BtnRestartService
- //
- this.BtnRestartService.BackColor = System.Drawing.SystemColors.ControlLight;
- this.BtnRestartService.Location = new System.Drawing.Point(392, 136);
- this.BtnRestartService.Name = "BtnRestartService";
- this.BtnRestartService.Size = new System.Drawing.Size(80, 23);
- this.BtnRestartService.TabIndex = 3;
- this.BtnRestartService.Text = "Redemarrer";
- this.BtnRestartService.Click += new System.EventHandler(this.BtnRestartService_Click);
- //
- // BtnPauseService
- //
- this.BtnPauseService.BackColor = System.Drawing.SystemColors.ControlLight;
- this.BtnPauseService.Location = new System.Drawing.Point(396, 84);
- this.BtnPauseService.Name = "BtnPauseService";
- this.BtnPauseService.Size = new System.Drawing.Size(72, 23);
- this.BtnPauseService.TabIndex = 2;
- this.BtnPauseService.Text = "Suspendre";
- this.BtnPauseService.Click += new System.EventHandler(this.BtnPauseService_Click);
- //
- // btnStartService
- //
- this.btnStartService.BackColor = System.Drawing.SystemColors.ControlLight;
- this.btnStartService.Location = new System.Drawing.Point(400, 20);
- this.btnStartService.Name = "btnStartService";
- this.btnStartService.Size = new System.Drawing.Size(64, 23);
- this.btnStartService.TabIndex = 1;
- this.btnStartService.Text = "Demarrer";
- this.btnStartService.Click += new System.EventHandler(this.btnStartService_Click);
- //
- // listeServices
- //
- this.listeServices.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
- this.columnNomServices,
- this.columnNomConvivial,
- this.columnEtat});
- this.listeServices.Location = new System.Drawing.Point(12, 32);
- this.listeServices.Name = "listeServices";
- this.listeServices.Size = new System.Drawing.Size(350, 250);
- this.listeServices.TabIndex = 0;
- this.listeServices.View = System.Windows.Forms.View.Details;
- //
- // columnNomServices
- //
- this.columnNomServices.Text = "Nom Service";
- this.columnNomServices.Width = 90;
- //
- // columnNomConvivial
- //
- this.columnNomConvivial.Text = "Nom Détaillé";
- this.columnNomConvivial.Width = 90;
- //
- // columnEtat
- //
- this.columnEtat.Text = "Etat";
- this.columnEtat.Width = 70;
- //
- // pictureBox1
- //
- this.pictureBox1.Image = ((System.Drawing.Bitmap)(resources.GetObject("pictureBox1.Image")));
- this.pictureBox1.Location = new System.Drawing.Point(4, 8);
- this.pictureBox1.Name = "pictureBox1";
- this.pictureBox1.Size = new System.Drawing.Size(504, 76);
- this.pictureBox1.TabIndex = 1;
- this.pictureBox1.TabStop = false;
- //
- // Form1
- //
- this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
- this.BackColor = System.Drawing.SystemColors.ActiveBorder;
- this.ClientSize = new System.Drawing.Size(512, 409);
- this.Controls.AddRange(new System.Windows.Forms.Control[] {
- this.pictureBox1,
- this.tabOnglet});
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
- this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
- this.MaximizeBox = false;
- this.Menu = this.BarreDeMenu;
- this.Name = "Form1";
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
- this.Text = "Rapid Task Access";
- this.tabOnglet.ResumeLayout(false);
- this.tabPage1.ResumeLayout(false);
- this.tabPage3.ResumeLayout(false);
- this.tabPage2.ResumeLayout(false);
- this.ResumeLayout(false);
-
- }
- #endregion
-
- /// <summary>
- /// Point d'entrée principal de l'application.
- /// </summary>
- [STAThread]
- static void Main()
- {
- Application.Run(new Form1());
- }
-
-
- //----------------------------------------------
- // Ci dessous, toutes les actions de nos boutons
- //----------------------------------------------
-
-
- //Bouton rafraichi les services
- private void BtnRefreshServices_Click(object sender, System.EventArgs e)
- {
- AvoirServices();
- }
-
-
- //Bouton rafraichi les drivers
- private void BtnRefreshDrivers_Click(object sender, System.EventArgs e)
- {
- AvoirDrivers();
- }
-
-
- //Bouton rafraichi les processus
- private void BtnRefreshProcess_Click(object sender, System.EventArgs e)
- {
- AvoirProcessus();
- }
-
-
- //Bouton Demarre un service
- private void btnStartService_Click(object sender, System.EventArgs e)
- {
- try
- {
- int SelectionCourante;
- int count=listeServices.SelectedItems.Count;
- if (count==0)
- return;
-
- SelectionCourante=listeServices.FocusedItem.Index;
- ServiceController monservice;
- ServiceController [] services=ServiceController.GetServices();
- monservice=services[SelectionCourante];
- if (monservice.Status==ServiceControllerStatus.Stopped)
- {
- monservice.Start();
- }
- else
- {
- MessageBox.Show("Service déjà activé !");
- }
- AvoirServices();
- }
- catch
- {
- MessageBox.Show("Erreur de démarrage de Services");
- }
- }
-
-
- //Bouton arretant les services
- private void BtnStopService_Click(object sender, System.EventArgs e)
- {
- try
- {
-
- int SelectionCourante;
- int count=listeServices.SelectedItems.Count;
- if (count==0)
- return;
-
- SelectionCourante=listeServices.FocusedItem.Index;
- ServiceController monservice;
- ServiceController [] services=ServiceController.GetServices();
- monservice=services[SelectionCourante];
- if (monservice.Status==ServiceControllerStatus.Running)
- {
- monservice.Stop();
- }
- else
- {
- MessageBox.Show("Service déjà arrété !");
- }
- AvoirServices();
- }
- catch
- {
- MessageBox.Show("Erreur lors de l'arret du Service");
- }
- }
-
-
- //Bouton pause sur un service
- private void BtnPauseService_Click(object sender, System.EventArgs e)
- {
- try
- {
- int SelectionCourante;
- int count=listeServices.SelectedItems.Count;
- if (count==0)
- return;
-
- SelectionCourante=listeServices.FocusedItem.Index;
- ServiceController monservice;
- ServiceController [] services=ServiceController.GetServices();
- monservice=services[SelectionCourante];
- if (monservice.Status==ServiceControllerStatus.Running)
- {
- monservice.Pause();
- }
- else
- {
- MessageBox.Show("Service non en pause !");
- }
- AvoirServices();
- }
- catch
- {
- MessageBox.Show("Erreur lors de la mise en pause du Service");
- }
- }
-
-
- //Bouton redemarre un service
- private void BtnRestartService_Click(object sender, System.EventArgs e)
- {
- try
- {
-
- int SelectionCourante;
- int count=listeServices.SelectedItems.Count;
- if (count==0)
- return;
-
- SelectionCourante=listeServices.FocusedItem.Index;
- ServiceController monservice;
- ServiceController [] services=ServiceController.GetServices();
- monservice=services[SelectionCourante];
- if (monservice.Status==ServiceControllerStatus.Paused)
- {
- monservice.Continue();
- }
- else
- {
- MessageBox.Show("Service non en pause !");
- }
- AvoirServices();
- }
- catch
- {
- MessageBox.Show("Erreur lors du redémarrage du Service");
- }
- }
-
-
- //Bouton Fermeture d'un processus
- private void BtnCloseProcess_Click(object sender, System.EventArgs e)
- {
- try
- {
-
- int SelectionCourante;
- int count=listeProcessus.SelectedItems.Count;
- if (count==0)
- return;
-
- SelectionCourante=listeProcessus.FocusedItem.Index;
- Process monprocessus;
- Process [] myprocess=Process.GetProcesses();
- monprocessus=myprocess[SelectionCourante];
-
- DialogResult dav = MessageBox.Show("Etes vous sur de vouloir fermer ce processus?(Cela pouvant occasionner des pertes de données ou autres sur votre ordinateur!)","Avertissement!",MessageBoxButtons.YesNo,MessageBoxIcon.Information);
- if(dav == DialogResult.Yes)
- {
- monprocessus.Kill();
- }
- AvoirProcessus();
- }
- catch
- {
- MessageBox.Show("Erreur lors de la fermeture de ce Service");
- }
- }
-
-
- //Bouton nouveau processus
- private void btnNewProcess_Click(object sender, System.EventArgs e)
- {
- NewTask nt = new NewTask();
- nt.ShowDialog();
- }
-
-
- //Bouton nouveau processus
- private void ExecuteItem_Click(object sender, System.EventArgs e)
- {
- NewTask nt = new NewTask();
- nt.ShowDialog();
- }
-
-
- private void menuExit_Click(object sender, System.EventArgs e)
- {
- DialogResult dr = MessageBox.Show("Voulez vous réellement quitter l'application ?","Quitter l'application",MessageBoxButtons.YesNo, MessageBoxIcon.Information);
- if(dr == DialogResult.Yes)
- {
- Application.Exit();
- }
- }
-
-
- private void menuHelp_Click(object sender, System.EventArgs e)
- {
- Process.Start("index.htm");
- }
-
- private void AboutProjectItem_Click(object sender, System.EventArgs e)
- {
- /*C'est une windows form a part. Je n'ai pu mettre le code dsl.
- Téléchargez le src pr mieux le voir */
- Apropos ap = new Apropos();
- ap.ShowDialog();
- }
-
- }
- }
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.ServiceProcess;
using System.Web;
using System.Diagnostics;
using System.Threading;
using System.IO;
namespace My_PCO
{
/// <summary>
/// Ce Programme fait le listing des services, drivers et processus Windows.
/// Il y a entre autres la possibilité de pouvoir influer sur certaines options
/// (Arret, Démarrage, Pause, Redemarrage pour les services),
/// (Terminer, Nouveau pour les processus)
/// et un Refresh pour les drivers.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.MenuItem InterrogationItem;
private System.Windows.Forms.MenuItem AboutProjectItem;
private System.Windows.Forms.MainMenu BarreDeMenu;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.TabControl tabOnglet;
private System.Windows.Forms.MenuItem menuFichier;
private System.Windows.Forms.MenuItem ExecuteItem;
private System.Windows.Forms.TabPage tabPage2;
private System.Windows.Forms.ListView listeProcessus;
private System.Windows.Forms.TabPage tabPage3;
private System.Windows.Forms.ListView listeServices;
private System.Windows.Forms.ListView listeDrivers;
private System.Windows.Forms.ColumnHeader columnNomServices;
private System.Windows.Forms.ColumnHeader columnEtat;
private System.Windows.Forms.ColumnHeader columnNomConvivial;
private System.Windows.Forms.ColumnHeader columnNomDriver;
private System.Windows.Forms.ColumnHeader columnNomDriverConvivial;
private System.Windows.Forms.ColumnHeader columnEtatDriver;
private System.Windows.Forms.ColumnHeader columnNomProcessus;
private System.Windows.Forms.Button BtnCloseProcess;
private System.Windows.Forms.Button btnStartService;
private System.Windows.Forms.Button BtnPauseService;
private System.Windows.Forms.Button BtnRestartService;
private System.Windows.Forms.Button BtnStopService;
private System.Windows.Forms.Button BtnRefreshProcess;
private System.Windows.Forms.Button BtnRefreshServices;
private System.Windows.Forms.Button BtnRefreshDrivers;
private System.Windows.Forms.ColumnHeader columnId;
private System.Windows.Forms.ColumnHeader columnMemoire;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.MenuItem menuHelp;
private System.Windows.Forms.MenuItem menuExit;
/// <summary>
/// Variable nécessaire au concepteur.
/// </summary>
private System.ComponentModel.Container components = null;
//Fonction permettant d'obtenir la liste de tous les processus
//et de les afficher dans une listView listeProcessus.
protected void AvoirProcessus()
{
try
{
//Variables dans lesquelles nous récupèrerons qques données des processus
string Nom_Processus, number_id, process_memory;
listeProcessus.Items.Clear();
foreach(Process myProcess in Process.GetProcesses())
{
Nom_Processus=myProcess.ProcessName; //retourne le nom des processus
number_id=myProcess.Id.ToString(); //leur id
process_memory=myProcess.NonpagedSystemMemorySize.ToString()+" ko"; // leur mémoire paginée
listeProcessus.Items.Add(new ListViewItem(new string[]{Nom_Processus, number_id, process_memory}));
}
}
catch
{
MessageBox.Show("Impossible de lister les processus");
}
}
//Fonction permettant d'obtenir la liste de tous les Services
//et de les afficher dans une listView listeServices
protected void AvoirServices()
{
try
{
string Nom_Service, Nom_Complet, Etat="";
listeServices.Items.Clear();
foreach (ServiceController monservice in ServiceController.GetServices())
{
Nom_Service=monservice.ServiceName;
Nom_Complet=monservice.DisplayName;
if (monservice.Status==ServiceControllerStatus.Stopped)
Etat="Arrêté";
if (monservice.Status==ServiceControllerStatus.Running)
Etat="Démarré";
if (monservice.Status==ServiceControllerStatus.Paused)
Etat="En pause";
listeServices.Items.Add(new ListViewItem(new string[]{Nom_Service, Nom_Complet, Etat}));
}
}
catch
{
MessageBox.Show("Impossible de lister les services");
}
}
//Fonction faisant la liste de tous les Drivers
protected void AvoirDrivers()
{
try
{
string Nom_Drivers,Nom_Complet, Etat="";
listeDrivers.Items.Clear();
foreach (ServiceController mondriver in ServiceController.GetDevices())
{
Nom_Drivers=mondriver.ServiceName;
Nom_Complet=mondriver.DisplayName;
if (mondriver.Status==ServiceControllerStatus.Stopped)
Etat="Arrêté";
if (mondriver.Status==ServiceControllerStatus.Running)
Etat="Démarré";
if (mondriver.Status==ServiceControllerStatus.Paused)
Etat="En pause";
listeDrivers.Items.Add(new ListViewItem(new string[]{Nom_Drivers, Nom_Complet, Etat}));
}
}
catch
{
MessageBox.Show("Impossible de lister les drivers");
}
}
public Form1()
{
//
// Requis pour la prise en charge du Concepteur Windows Forms
//
// Nous initialisons nos différents affichages, Services, Drivers et Processus
InitializeComponent();
AvoirServices();
AvoirDrivers();
AvoirProcessus();
//
// TODO : ajoutez le code du constructeur après l'appel à InitializeComponent
//
}
/// <summary>
/// Nettoyage des ressources utilisées.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Méthode requise pour la prise en charge du concepteur - ne modifiez pas
/// le contenu de cette méthode avec l'éditeur de code.
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.BarreDeMenu = new System.Windows.Forms.MainMenu();
this.menuFichier = new System.Windows.Forms.MenuItem();
this.ExecuteItem = new System.Windows.Forms.MenuItem();
this.menuExit = new System.Windows.Forms.MenuItem();
this.InterrogationItem = new System.Windows.Forms.MenuItem();
this.AboutProjectItem = new System.Windows.Forms.MenuItem();
this.menuHelp = new System.Windows.Forms.MenuItem();
this.tabOnglet = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.BtnRefreshProcess = new System.Windows.Forms.Button();
this.BtnCloseProcess = new System.Windows.Forms.Button();
this.listeProcessus = new System.Windows.Forms.ListView();
this.columnNomProcessus = new System.Windows.Forms.ColumnHeader();
this.columnId = new System.Windows.Forms.ColumnHeader();
this.columnMemoire = new System.Windows.Forms.ColumnHeader();
this.tabPage3 = new System.Windows.Forms.TabPage();
this.BtnRefreshDrivers = new System.Windows.Forms.Button();
this.listeDrivers = new System.Windows.Forms.ListView();
this.columnNomDriver = new System.Windows.Forms.ColumnHeader();
this.columnNomDriverConvivial = new System.Windows.Forms.ColumnHeader();
this.columnEtatDriver = new System.Windows.Forms.ColumnHeader();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.BtnRefreshServices = new System.Windows.Forms.Button();
this.BtnStopService = new System.Windows.Forms.Button();
this.BtnRestartService = new System.Windows.Forms.Button();
this.BtnPauseService = new System.Windows.Forms.Button();
this.btnStartService = new System.Windows.Forms.Button();
this.listeServices = new System.Windows.Forms.ListView();
this.columnNomServices = new System.Windows.Forms.ColumnHeader();
this.columnNomConvivial = new System.Windows.Forms.ColumnHeader();
this.columnEtat = new System.Windows.Forms.ColumnHeader();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.tabOnglet.SuspendLayout();
this.tabPage1.SuspendLayout();
this.tabPage3.SuspendLayout();
this.tabPage2.SuspendLayout();
this.SuspendLayout();
//
// BarreDeMenu
//
this.BarreDeMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuFichier,
this.InterrogationItem});
//
// menuFichier
//
this.menuFichier.Index = 0;
this.menuFichier.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.ExecuteItem,
this.menuExit});
this.menuFichier.Text = "Fichier";
//
// ExecuteItem
//
this.ExecuteItem.Index = 0;
this.ExecuteItem.Text = "Executer";
this.ExecuteItem.Click += new System.EventHandler(this.ExecuteItem_Click);
//
// menuExit
//
this.menuExit.Index = 1;
this.menuExit.Text = "Exit";
this.menuExit.Click += new System.EventHandler(this.menuExit_Click);
//
// InterrogationItem
//
this.InterrogationItem.Index = 1;
this.InterrogationItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.AboutProjectItem,
this.menuHelp});
this.InterrogationItem.Text = "?";
//
// AboutProjectItem
//
this.AboutProjectItem.Index = 0;
this.AboutProjectItem.Text = "A propos!";
this.AboutProjectItem.Click += new System.EventHandler(this.AboutProjectItem_Click);
//
// menuHelp
//
this.menuHelp.Index = 1;
this.menuHelp.Text = "Help!!";
this.menuHelp.Click += new System.EventHandler(this.menuHelp_Click);
//
// tabOnglet
//
this.tabOnglet.Controls.AddRange(new System.Windows.Forms.Control[] {
this.tabPage1,
this.tabPage3,
this.tabPage2});
this.tabOnglet.Dock = System.Windows.Forms.DockStyle.Bottom;
this.tabOnglet.Location = new System.Drawing.Point(0, 89);
this.tabOnglet.Name = "tabOnglet";
this.tabOnglet.SelectedIndex = 0;
this.tabOnglet.Size = new System.Drawing.Size(512, 320);
this.tabOnglet.TabIndex = 0;
//
// tabPage1
//
this.tabPage1.Controls.AddRange(new System.Windows.Forms.Control[] {
this.BtnRefreshProcess,
this.BtnCloseProcess,
this.listeProcessus});
this.tabPage1.Location = new System.Drawing.Point(4, 22);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Size = new System.Drawing.Size(504, 294);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "Processus";
//
// BtnRefreshProcess
//
this.BtnRefreshProcess.BackColor = System.Drawing.SystemColors.ControlLight;
this.BtnRefreshProcess.Location = new System.Drawing.Point(400, 260);
this.BtnRefreshProcess.Name = "BtnRefreshProcess";
this.BtnRefreshProcess.TabIndex = 3;
this.BtnRefreshProcess.Text = "Refresh";
this.BtnRefreshProcess.Click += new System.EventHandler(this.BtnRefreshProcess_Click);
//
// BtnCloseProcess
//
this.BtnCloseProcess.BackColor = System.Drawing.SystemColors.ControlLight;
this.BtnCloseProcess.Location = new System.Drawing.Point(372, 56);
this.BtnCloseProcess.Name = "BtnCloseProcess";
this.BtnCloseProcess.Size = new System.Drawing.Size(128, 23);
this.BtnCloseProcess.TabIndex = 2;
this.BtnCloseProcess.Text = "Terminer le Processus";
this.BtnCloseProcess.Click += new System.EventHandler(this.BtnCloseProcess_Click);
//
// listeProcessus
//
this.listeProcessus.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnNomProcessus,
this.columnId,
this.columnMemoire});
this.listeProcessus.Location = new System.Drawing.Point(12, 32);
this.listeProcessus.Name = "listeProcessus";
this.listeProcessus.Size = new System.Drawing.Size(350, 250);
this.listeProcessus.TabIndex = 0;
this.listeProcessus.View = System.Windows.Forms.View.Details;
//
// columnNomProcessus
//
this.columnNomProcessus.Text = "Nom Processus";
this.columnNomProcessus.Width = 90;
//
// columnId
//
this.columnId.Text = "Id";
//
// columnMemoire
//
this.columnMemoire.Text = "Memoire";
//
// tabPage3
//
this.tabPage3.Controls.AddRange(new System.Windows.Forms.Control[] {
this.BtnRefreshDrivers,
this.listeDrivers});
this.tabPage3.Location = new System.Drawing.Point(4, 22);
this.tabPage3.Name = "tabPage3";
this.tabPage3.Size = new System.Drawing.Size(504, 294);
this.tabPage3.TabIndex = 2;
this.tabPage3.Text = "Drivers";
//
// BtnRefreshDrivers
//
this.BtnRefreshDrivers.BackColor = System.Drawing.SystemColors.ControlLight;
this.BtnRefreshDrivers.Location = new System.Drawing.Point(400, 260);
this.BtnRefreshDrivers.Name = "BtnRefreshDrivers";
this.BtnRefreshDrivers.TabIndex = 1;
this.BtnRefreshDrivers.Text = "Refresh";
this.BtnRefreshDrivers.Click += new System.EventHandler(this.BtnRefreshDrivers_Click);
//
// listeDrivers
//
this.listeDrivers.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnNomDriver,
this.columnNomDriverConvivial,
this.columnEtatDriver});
this.listeDrivers.Location = new System.Drawing.Point(12, 32);
this.listeDrivers.Name = "listeDrivers";
this.listeDrivers.Size = new System.Drawing.Size(350, 250);
this.listeDrivers.TabIndex = 0;
this.listeDrivers.View = System.Windows.Forms.View.Details;
//
// columnNomDriver
//
this.columnNomDriver.Text = "Nom du Driver";
this.columnNomDriver.Width = 90;
//
// columnNomDriverConvivial
//
this.columnNomDriverConvivial.Text = "Nom Détaillé";
this.columnNomDriverConvivial.Width = 90;
//
// columnEtatDriver
//
this.columnEtatDriver.Text = "Etat";
//
// tabPage2
//
this.tabPage2.Controls.AddRange(new System.Windows.Forms.Control[] {
this.BtnRefreshServices,
this.BtnStopService,
this.BtnRestartService,
this.BtnPauseService,
this.btnStartService,
this.listeServices});
this.tabPage2.Location = new System.Drawing.Point(4, 22);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Size = new System.Drawing.Size(504, 294);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "Services";
//
// BtnRefreshServices
//
this.BtnRefreshServices.BackColor = System.Drawing.SystemColors.ControlLight;
this.BtnRefreshServices.Location = new System.Drawing.Point(400, 260);
this.BtnRefreshServices.Name = "BtnRefreshServices";
this.BtnRefreshServices.TabIndex = 5;
this.BtnRefreshServices.Text = "Refresh";
this.BtnRefreshServices.Click += new System.EventHandler(this.BtnRefreshServices_Click);
//
// BtnStopService
//
this.BtnStopService.BackColor = System.Drawing.SystemColors.ControlLight;
this.BtnStopService.Location = new System.Drawing.Point(404, 200);
this.BtnStopService.Name = "BtnStopService";
this.BtnStopService.Size = new System.Drawing.Size(64, 23);
this.BtnStopService.TabIndex = 4;
this.BtnStopService.Text = "Arreter";
this.BtnStopService.Click += new System.EventHandler(this.BtnStopService_Click);
//
// BtnRestartService
//
this.BtnRestartService.BackColor = System.Drawing.SystemColors.ControlLight;
this.BtnRestartService.Location = new System.Drawing.Point(392, 136);
this.BtnRestartService.Name = "BtnRestartService";
this.BtnRestartService.Size = new System.Drawing.Size(80, 23);
this.BtnRestartService.TabIndex = 3;
this.BtnRestartService.Text = "Redemarrer";
this.BtnRestartService.Click += new System.EventHandler(this.BtnRestartService_Click);
//
// BtnPauseService
//
this.BtnPauseService.BackColor = System.Drawing.SystemColors.ControlLight;
this.BtnPauseService.Location = new System.Drawing.Point(396, 84);
this.BtnPauseService.Name = "BtnPauseService";
this.BtnPauseService.Size = new System.Drawing.Size(72, 23);
this.BtnPauseService.TabIndex = 2;
this.BtnPauseService.Text = "Suspendre";
this.BtnPauseService.Click += new System.EventHandler(this.BtnPauseService_Click);
//
// btnStartService
//
this.btnStartService.BackColor = System.Drawing.SystemColors.ControlLight;
this.btnStartService.Location = new System.Drawing.Point(400, 20);
this.btnStartService.Name = "btnStartService";
this.btnStartService.Size = new System.Drawing.Size(64, 23);
this.btnStartService.TabIndex = 1;
this.btnStartService.Text = "Demarrer";
this.btnStartService.Click += new System.EventHandler(this.btnStartService_Click);
//
// listeServices
//
this.listeServices.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnNomServices,
this.columnNomConvivial,
this.columnEtat});
this.listeServices.Location = new System.Drawing.Point(12, 32);
this.listeServices.Name = "listeServices";
this.listeServices.Size = new System.Drawing.Size(350, 250);
this.listeServices.TabIndex = 0;
this.listeServices.View = System.Windows.Forms.View.Details;
//
// columnNomServices
//
this.columnNomServices.Text = "Nom Service";
this.columnNomServices.Width = 90;
//
// columnNomConvivial
//
this.columnNomConvivial.Text = "Nom Détaillé";
this.columnNomConvivial.Width = 90;
//
// columnEtat
//
this.columnEtat.Text = "Etat";
this.columnEtat.Width = 70;
//
// pictureBox1
//
this.pictureBox1.Image = ((System.Drawing.Bitmap)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(4, 8);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(504, 76);
this.pictureBox1.TabIndex = 1;
this.pictureBox1.TabStop = false;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackColor = System.Drawing.SystemColors.ActiveBorder;
this.ClientSize = new System.Drawing.Size(512, 409);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.pictureBox1,
this.tabOnglet});
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.Menu = this.BarreDeMenu;
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Rapid Task Access";
this.tabOnglet.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.tabPage3.ResumeLayout(false);
this.tabPage2.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// Point d'entrée principal de l'application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
//----------------------------------------------
// Ci dessous, toutes les actions de nos boutons
//----------------------------------------------
//Bouton rafraichi les services
private void BtnRefreshServices_Click(object sender, System.EventArgs e)
{
AvoirServices();
}
//Bouton rafraichi les drivers
private void BtnRefreshDrivers_Click(object sender, System.EventArgs e)
{
AvoirDrivers();
}
//Bouton rafraichi les processus
private void BtnRefreshProcess_Click(object sender, System.EventArgs e)
{
AvoirProcessus();
}
//Bouton Demarre un service
private void btnStartService_Click(object sender, System.EventArgs e)
{
try
{
int SelectionCourante;
int count=listeServices.SelectedItems.Count;
if (count==0)
return;
SelectionCourante=listeServices.FocusedItem.Index;
ServiceController monservice;
ServiceController [] services=ServiceController.GetServices();
monservice=services[SelectionCourante];
if (monservice.Status==ServiceControllerStatus.Stopped)
{
monservice.Start();
}
else
{
MessageBox.Show("Service déjà activé !");
}
AvoirServices();
}
catch
{
MessageBox.Show("Erreur de démarrage de Services");
}
}
//Bouton arretant les services
private void BtnStopService_Click(object sender, System.EventArgs e)
{
try
{
int SelectionCourante;
int count=listeServices.SelectedItems.Count;
if (count==0)
return;
SelectionCourante=listeServices.FocusedItem.Index;
ServiceController monservice;
ServiceController [] services=ServiceController.GetServices();
monservice=services[SelectionCourante];
if (monservice.Status==ServiceControllerStatus.Running)
{
monservice.Stop();
}
else
{
MessageBox.Show("Service déjà arrété !");
}
AvoirServices();
}
catch
{
MessageBox.Show("Erreur lors de l'arret du Service");
}
}
//Bouton pause sur un service
private void BtnPauseService_Click(object sender, System.EventArgs e)
{
try
{
int SelectionCourante;
int count=listeServices.SelectedItems.Count;
if (count==0)
return;
SelectionCourante=listeServices.FocusedItem.Index;
ServiceController monservice;
ServiceController [] services=ServiceController.GetServices();
monservice=services[SelectionCourante];
if (monservice.Status==ServiceControllerStatus.Running)
{
monservice.Pause();
}
else
{
MessageBox.Show("Service non en pause !");
}
AvoirServices();
}
catch
{
MessageBox.Show("Erreur lors de la mise en pause du Service");
}
}
//Bouton redemarre un service
private void BtnRestartService_Click(object sender, System.EventArgs e)
{
try
{
int SelectionCourante;
int count=listeServices.SelectedItems.Count;
if (count==0)
return;
SelectionCourante=listeServices.FocusedItem.Index;
ServiceController monservice;
ServiceController [] services=ServiceController.GetServices();
monservice=services[SelectionCourante];
if (monservice.Status==ServiceControllerStatus.Paused)
{
monservice.Continue();
}
else
{
MessageBox.Show("Service non en pause !");
}
AvoirServices();
}
catch
{
MessageBox.Show("Erreur lors du redémarrage du Service");
}
}
//Bouton Fermeture d'un processus
private void BtnCloseProcess_Click(object sender, System.EventArgs e)
{
try
{
int SelectionCourante;
int count=listeProcessus.SelectedItems.Count;
if (count==0)
return;
SelectionCourante=listeProcessus.FocusedItem.Index;
Process monprocessus;
Process [] myprocess=Process.GetProcesses();
monprocessus=myprocess[SelectionCourante];
DialogResult dav = MessageBox.Show("Etes vous sur de vouloir fermer ce processus?(Cela pouvant occasionner des pertes de données ou autres sur votre ordinateur!)","Avertissement!",MessageBoxButtons.YesNo,MessageBoxIcon.Information);
if(dav == DialogResult.Yes)
{
monprocessus.Kill();
}
AvoirProcessus();
}
catch
{
MessageBox.Show("Erreur lors de la fermeture de ce Service");
}
}
//Bouton nouveau processus
private void btnNewProcess_Click(object sender, System.EventArgs e)
{
NewTask nt = new NewTask();
nt.ShowDialog();
}
//Bouton nouveau processus
private void ExecuteItem_Click(object sender, System.EventArgs e)
{
NewTask nt = new NewTask();
nt.ShowDialog();
}
private void menuExit_Click(object sender, System.EventArgs e)
{
DialogResult dr = MessageBox.Show("Voulez vous réellement quitter l'application ?","Quitter l'application",MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if(dr == DialogResult.Yes)
{
Application.Exit();
}
}
private void menuHelp_Click(object sender, System.EventArgs e)
{
Process.Start("index.htm");
}
private void AboutProjectItem_Click(object sender, System.EventArgs e)
{
/*C'est une windows form a part. Je n'ai pu mettre le code dsl.
Téléchargez le src pr mieux le voir */
Apropos ap = new Apropos();
ap.ShowDialog();
}
}
}
Conclusion
C'est une version béta. J'envisage de la mettre à jour, mais pas tout de suite. il est open source, donc, profitez en, mettez le à jour si vous le désirez, montrez moi vos versions améliorées, etc...
Sources du même auteur
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
Applet, Process et WMI [ par lazz59 ]
Bonjour, J'ai créé une applet en .Net C# tel qu'il l'est expliqué sur ce site : http://fr.gotdotnet.com/quickstart/winforms/doc/Wi
Processus et Windows CE [ par tfrancais ]
Bonjour, Est-ce qu'il est possible de contrôler le nombre de scession pour une applications sous Windows CE comme on peut le faire sous Windows
Attendre que le processus soit lancé pour fermer la fenêtre... [ par XBOX116_4ever ]
Voilà, Précédemment, j'ai obtenu de l'aide pour lancer un processus. Je voudrait que ma fenêtre qui dit de patienté se ferme
Liste des fenetres des processus [ par AlanG ]
bonjour,Je cherche comment obtenir la liste des fenêtres de chaque process (en code managé si possible). Pour la liste des process pas de pr
cacher le nom d'un processus dans le gestionnaire des tâches de windows [ par alexSot ]
salut chers amis, je lance mon application que j'ai dénommé gestionNet et je voudrais pas qu'un utlisateur averti puisse aller arrêter l'application d
problème pour bloquer un processus [ par gretata ]
bonjour a tous !!j'ai un petit problème pour bloquer un processus,//dans le constructeurProcessStartInfo pro;<font color="#
Killer un processus : bonne méthode? [ par clubberzZ ]
Bonjour, pour tuer un processus j'utilise cette méthode : private void KillProcess(string processName) { // liste des processus ayant ce nom Proc
Lancement de processus distant [ par olden ]
Bonjour, J'utilise le WMI afin delancer des process sur un poste distant, sauf que mon process apparait bien dans le gestionnaire des tâches, mais la
Process.... [ par Paladin2107 ]
Tout d'abord bonjour à tousJe m'adresse à vous car j'ai un souci à propos d'un processus.Lorsque je l'exécute dans une fenêtre dos elle fonctionne cor
Savoir si un processus est actif / erreur if:else [ par Cactuz ]
Bonsoir à tous. Je cherche actuellement à créer un programme qui relancerai un processus si il s'est arrêté pour une raison quelconque. Il faut donc a
|
Derniers Blogs
UNE JOLIE-HORLOGE ET PAS QU'UN PEU !UNE JOLIE-HORLOGE ET PAS QU'UN PEU ! par neodante
Pour les possesseurs d'iPhone, ça y est Bijin Tokei - qui se traduit littéralement en Français par " Jolie Horloge " - est arrivé et GRATUITEMENT s'il vous plaît ! Après la version Tokyo, Hokkaido, night club, racing, Gal, "pour les mademoiselles'", . voi...
Cliquez pour lire la suite de l'article par neodante TECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICESTECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICES par ROMELARD Fabrice
Animé par: Gaetan Bouveret et Julien Chomarat Business Connectivity Services (BCS) est dans SharePoint 2010 la version 2 de Business Data Catalog (BDC dans SharePoint 2007). Il s'agit de la solution permettant de visualiser des données provenan...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice [DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE[DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE par orion
Comme de nombreux geek, je suis un grand amateur de série TV et je rate régulièrement des épisodes de mes séries préférés. Une solution s'offre à vous avec ce merveilleux site : Tv Gorge - www.tvgorge.com Moteur de recherche à l'appui, vous pouvez ...
Cliquez pour lire la suite de l'article par orion TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Vincent Bellet et Baptiste Giraudier La BI dans SharePoint 2010, Les nouveaux services d'application dans SP2010 et SQL Server Reporting services 2008 R2. La BI dans SharePoint est généralisée pour tous afin de permettre à tous les coll...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Logiciels
DB-MAIN (9.1.0)DB-MAIN (9.1.0)DB-MAIN is a data-modeling and data-architecture tool. It is designed to help developers and anal... Cliquez pour télécharger DB-MAIN Xilisoft DPG Convertisseur (5.1.37.0120)XILISOFT DPG CONVERTISSEUR (5.1.37.0120)Xilisoft DPG Convertisseur offre aux fans de Nintendo DS une bonne solution leur permettant de dé... Cliquez pour télécharger Xilisoft DPG Convertisseur GraphicsGale (2.01.01)GRAPHICSGALE (2.01.01)GraphicsGale est un logiciel de PixelArt avec de nombreuse fonctionnalités permettant de réalisé ... Cliquez pour télécharger GraphicsGale Architecte 3D (Platinum 2010)ARCHITECTE 3D (PLATINUM 2010)Architecte 3D Platinium vous permet de concevoir facilement les plans votre future maison, de l'é... Cliquez pour télécharger Architecte 3D TeamViewer 5 (TeamViewer 5)TEAMVIEWER 5 (TEAMVIEWER 5)Dépanner un ami,expliquer une manipulation devient un jeu d'enfant.
Prise en main d'un autre ord... Cliquez pour télécharger TeamViewer 5
|