System.Diagnostics


Bibliothèque de classes .NET Framework
ProcessStartInfo, classe

Spécifie un jeu de valeurs utilisé lors du démarrage d'un processus.

Espace de noms : System.Diagnostics
Assembly : System (dans system.dll)

Syntaxe

Visual Basic (Déclaration)
Public NotInheritable Class ProcessStartInfo
Visual Basic (Utilisation)
Dim instance As ProcessStartInfo
C#
public sealed class ProcessStartInfo
C++
public ref class ProcessStartInfo sealed
J#
public final class ProcessStartInfo
JScript
public final class ProcessStartInfo
Notes

RemarqueRemarque

L'attribut HostProtectionAttribute appliqué à cette classe a la valeur de propriété Resources suivante : SharedState | SelfAffectingProcessMgmt. HostProtectionAttribute n'affecte pas les applications bureautiques (qui sont généralement démarrées en double-cliquant sur une icône, en tapant une commande ou en entrant une URL dans un navigateur). Pour plus d'informations, consultez la classe HostProtectionAttribute ou Attributs de programmation et de protection des hôtes SQL Server.

ProcessStartInfo est utilisé conjointement avec le composant Process. Si vous démarrez un processus à l'aide de la classe Process, vous pouvez accéder à des informations à son sujet, en plus de celles fournies lors de l'attachement à un processus en cours d'exécution.

Vous pouvez utiliser la classe ProcessStartInfo pour disposer d'un meilleur contrôle sur le processus que vous démarrez. Vous devez au moins définir la propriété FileName, manuellement ou à l'aide du constructeur. Le nom de fichier est celui d'une application ou d'un document. Dans ce cas-ci, un document est défini comme un type de fichier auquel est associée une action d'ouverture ou une action par défaut. Vous pouvez afficher les types de fichiers inscrits, ainsi que les applications qui leur sont associées, pour l'ordinateur à l'aide de la boîte de dialogue Options des dossiers accessible par l'intermédiaire du système d'exploitation. Le bouton Avancées ouvre une boîte de dialogue qui affiche une valeur indiquant si une action d'ouverture est associée à un type de fichier inscrit déterminé.

En outre, vous pouvez définir d'autres propriétés qui précisent les actions à effectuer avec ce fichier. Vous pouvez spécifier une valeur propre au type de la propriété FileName pour la propriété Verb. Par exemple, vous pouvez spécifier "print" comme type de document. Vous pouvez également spécifier les valeurs de la propriété Arguments en tant qu'arguments de la ligne de commande à passer à la procédure d'ouverture du fichier. Par exemple, si vous spécifiez un éditeur de texte dans la propriété FileName, vous pouvez utiliser la propriété Arguments pour spécifier un fichier texte que l'éditeur doit ouvrir.

L'entrée standard est généralement le clavier, alors que la sortie et l'erreur standard sont généralement l'écran du moniteur. Cependant, vous pouvez utiliser les propriétés RedirectStandardInput, RedirectStandardOutput et RedirectStandardError pour que le processus obtienne une entrée ou retourne une sortie à un fichier ou un autre périphérique. Si vous utilisez les propriétés StandardInput, StandardOutput ou StandardError du composant Process, vous devez d'abord définir la valeur correspondante de la propriété ProcessStartInfo. Sinon, le système lève une exception lorsque vous lisez ou écrivez dans le flux.

Définissez UseShellExecute afin de spécifier si le processus doit être démarré à l'aide du shell du système d'exploitation.

Vous pouvez modifier la valeur de ces propriétés ProcessStartInfo jusqu'au démarrage du processus. Une fois le processus démarré, la modification de ces valeurs n'a aucun effet.

RemarqueRemarque

Cette classe contient une demande de liaison au niveau de la classe qui s'applique à tous les membres. SecurityException est levé lorsque l'appelant immédiat ne possède pas une autorisation de confiance totale. Pour plus d'informations sur les demandes de sécurité, consultez Demandes de liaison.

Exemple

Visual Basic
Imports System
Imports System.Diagnostics
Imports System.ComponentModel


Namespace MyProcessSample
    _
   '/ <summary>
   '/ Shell for the sample.
   '/ </summary>
   Class MyProcess 
      '/ <summary>
      '/ Opens the Internet Explorer application.
      '/ </summary>
      Public Sub OpenApplication(myFavoritesPath As String)
         ' Start Internet Explorer. Defaults to the home page.
         Process.Start("IExplore.exe")
         
         ' Display the contents of the favorites folder in the browser.
         Process.Start(myFavoritesPath)
      End Sub 'OpenApplication
       
      
      '/ <summary>
      '/ Opens urls and .html documents using Internet Explorer.
      '/ </summary>
      Sub OpenWithArguments()
         ' url's are not considered documents. They can only be opened
         ' by passing them as arguments.
         Process.Start("IExplore.exe", "www.northwindtraders.com")
         
         ' Start a Web page using a browser associated with .html and .asp files.
         Process.Start("IExplore.exe", "C:\myPath\myFile.htm")
         Process.Start("IExplore.exe", "C:\myPath\myFile.asp")
      End Sub 'OpenWithArguments
      
      
      '/ <summary>
      '/ Uses the ProcessStartInfo class to start new processes, both in a minimized 
      '/ mode.
      '/ </summary>
      Sub OpenWithStartInfo()
         
         Dim startInfo As New ProcessStartInfo("IExplore.exe")
         startInfo.WindowStyle = ProcessWindowStyle.Minimized
         
         Process.Start(startInfo)
         
         startInfo.Arguments = "www.northwindtraders.com"
         
         Process.Start(startInfo)
      End Sub 'OpenWithStartInfo
       
      
      Shared Sub Main()
         ' Get the path that stores favorite links.
         Dim myFavoritesPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Favorites)
         
         Dim myProcess As New MyProcess()
         
         myProcess.OpenApplication(myFavoritesPath)
         myProcess.OpenWithArguments()
         myProcess.OpenWithStartInfo()
      End Sub 'Main 
   End Class 'MyProcess
End Namespace 'MyProcessSample
C#
using System;
using System.Diagnostics;
using System.ComponentModel;

namespace MyProcessSample
{
    /// <summary>
    /// Shell for the sample.
    /// </summary>
    class MyProcess
    {
       
        /// <summary>
        /// Opens the Internet Explorer application.
        /// </summary>
        void OpenApplication(string myFavoritesPath)
        {
            // Start Internet Explorer. Defaults to the home page.
            Process.Start("IExplore.exe");
                    
            // Display the contents of the favorites folder in the browser.
            Process.Start(myFavoritesPath);
 
        }
        
        /// <summary>
        /// Opens urls and .html documents using Internet Explorer.
        /// </summary>
        void OpenWithArguments()
        {
            // url's are not considered documents. They can only be opened
            // by passing them as arguments.
            Process.Start("IExplore.exe", "www.northwindtraders.com");
            
            // Start a Web page using a browser associated with .html and .asp files.
            Process.Start("IExplore.exe", "C:\\myPath\\myFile.htm");
            Process.Start("IExplore.exe", "C:\\myPath\\myFile.asp");
        }
        
        /// <summary>
        /// Uses the ProcessStartInfo class to start new processes, both in a minimized 
        /// mode.
        /// </summary>
        void OpenWithStartInfo()
        {
            
            ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");
            startInfo.WindowStyle = ProcessWindowStyle.Minimized;
            
            Process.Start(startInfo);
            
            startInfo.Arguments = "www.northwindtraders.com";
            
            Process.Start(startInfo);
            
        }

        static void Main()
        {
                    // Get the path that stores favorite links.
                    string myFavoritesPath = 
                    Environment.GetFolderPath(Environment.SpecialFolder.Favorites);
                
                    MyProcess myProcess = new MyProcess();
         
            myProcess.OpenApplication(myFavoritesPath);
            myProcess.OpenWithArguments();
            myProcess.OpenWithStartInfo();

               }    
    }
}
C++
#using <System.dll>

using namespace System;
using namespace System::Diagnostics;
using namespace System::ComponentModel;

/// <summary>
/// Opens the Internet Explorer application.
/// </summary>
void OpenApplication( String^ myFavoritesPath )
{
   
   // Start Internet Explorer. Defaults to the home page.
   Process::Start( "IExplore.exe" );
   
   // Display the contents of the favorites folder in the browser.
   Process::Start( myFavoritesPath );
}


/// <summary>
/// Opens urls and .html documents using Internet Explorer.
/// </summary>
void OpenWithArguments()
{
   
   // url's are not considered documents. They can only be opened
   // by passing them as arguments.
   Process::Start( "IExplore.exe", "www.northwindtraders.com" );
   
   // Start a Web page using a browser associated with .html and .asp files.
   Process::Start( "IExplore.exe", "C:\\myPath\\myFile.htm" );
   Process::Start( "IExplore.exe", "C:\\myPath\\myFile.asp" );
}


/// <summary>
/// Uses the ProcessStartInfo class to start new processes, both in a minimized 
/// mode.
/// </summary>
void OpenWithStartInfo()
{
   ProcessStartInfo^ startInfo = gcnew ProcessStartInfo( "IExplore.exe" );
   startInfo->WindowStyle = ProcessWindowStyle::Minimized;
   Process::Start( startInfo );
   startInfo->Arguments = "www.northwindtraders.com";
   Process::Start( startInfo );
}

int main()
{
   
   // Get the path that stores favorite links.
   String^ myFavoritesPath = Environment::GetFolderPath( Environment::SpecialFolder::Favorites );
   OpenApplication( myFavoritesPath );
   OpenWithArguments();
   OpenWithStartInfo();
}
Sécurité .NET Framework

Hiérarchie d'héritage

System.Object
  System.Diagnostics.ProcessStartInfo
Sécurité des threads

Les membres statiques publics (Shared en Visual Basic) de ce type sont thread-safe. Il n'est pas garanti que les membres d'instance soient thread-safe.
Plates-formes

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile pour Pocket PC, Windows Mobile pour Smartphone, Windows Server 2003, Windows XP Édition Media Center, Windows XP Professionnel Édition x64, Windows XP SP2, Windows XP Starter Edition

Le .NET Framework ne prend pas en charge toutes les versions de chaque plate-forme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise.

Informations de version

.NET Framework

Prise en charge dans : 2.0, 1.1, 1.0

.NET Compact Framework

Prise en charge dans : 2.0
Voir aussi

Mots clés :


Page view tracker