ProcessStartInfo クラス
プロセスを起動するときに使用する値のセットを指定します。
この型のすべてのメンバの一覧については、ProcessStartInfo メンバ を参照してください。
System.Object
System.Diagnostics.ProcessStartInfo
NotInheritable Public Class ProcessStartInfo
[C#]
public sealed class ProcessStartInfo
[C++]
public __gc __sealed class ProcessStartInfo
[JScript]
public class ProcessStartInfo
スレッドセーフ
この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。
解説
ProcessStartInfo は、 Process コンポーネントと組み合わせて使用します。 Process クラスを使用してプロセスを起動すると、実行中のプロセスに接続するときに利用できる情報だけでなく、プロセス情報にもアクセスできます。
ProcessStartInfo クラスを使用して、起動するプロセスをさらに制御できます。少なくとも、手動またはコンストラクタを使用して、 FileName プロパティを設定する必要があります。ファイル名は、任意のアプリケーションまたはドキュメントにします。ここでいうドキュメントとは、"open" という既定のアクションが関連付けられている任意のファイル タイプです。登録されているファイル タイプと、コンピュータ上でこれらに関連付けられているアプリケーションは、オペレーティング システムを通じて利用できる [フォルダ オプション] ダイアログ ボックスで参照できます。[詳細設定] ボタンを使用すると、登録されている特定のファイル タイプに "open" アクションが関連付けられているかどうかを示すダイアログ ボックスが表示されます。
さらにその他のプロパティを設定して、そのファイルに対して実行するアクションを定義できます。 FileName プロパティの種類に固有の値を Verb プロパティに指定できます。たとえば、ドキュメントの種類に対して "印刷" を指定できます。さらに、ファイルのオープン プロシージャに渡すコマンド ライン引数になるように、 Arguments プロパティ値を指定できます。たとえば、 FileName プロパティにテキスト エディタ アプリケーションを指定すると、 Arguments プロパティを使用してエディタで開くテキスト ファイルを指定できます。
標準入力は通常、キーボードで、標準出力と標準エラー出力は通常、モニタ画面です。ただし、 RedirectStandardInput 、 RedirectStandardOutput 、 RedirectStandardError の各プロパティを使用すると、プロセスが入力を取得したり出力を返す先をファイルまたはその他のデバイスにできます。 Process コンポーネントの StandardInput 、 StandardOutput 、または StandardError の各プロパティを使用する場合は、まず対応する値を ProcessStartInfo プロパティに設定する必要があります。設定しないと、ストリームの読み取りまたは書き込みを実行したときに、例外がスローされます。
UseShellExecute を設定し、オペレーティング システムのシェルを使用してプロセスを起動するかどうかを指定します。
ProcessStartInfo プロパティの値を変更できるのは、プロセスを起動するまでです。プロセスを開始した後で、これらの値を変更しても影響はありません。
使用例
Imports System
Imports System.Diagnostics
Imports System.ComponentModel
Namespace MyProcessSample
_
'/ <summary>
'/ Shell for the sample.
'/ </summary>
Public 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>
Public 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>
Public 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
Public 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>
public class MyProcess
{
/// <summary>
/// Opens the Internet Explorer application.
/// </summary>
public 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>
public 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>
public void OpenWithStartInfo()
{
ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");
startInfo.WindowStyle = ProcessWindowStyle.Minimized;
Process.Start(startInfo);
startInfo.Arguments = "www.northwindtraders.com";
Process.Start(startInfo);
}
public 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 <mscorlib.dll>
#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(S"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(S"IExplore.exe", S"www.northwindtraders.com");
// Start a Web page using a browser associated with .html and .asp files.
Process::Start(S"IExplore.exe", S"C:\\myPath\\myFile.htm");
Process::Start(S"IExplore.exe", S"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(S"IExplore.exe");
startInfo->WindowStyle = ProcessWindowStyle::Minimized;
Process::Start(startInfo);
startInfo->Arguments = S"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();
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
名前空間: System.Diagnostics
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
アセンブリ: System (System.dll 内)