ProcessStartInfo.Verbs プロパティ
アセンブリ: System (system.dll 内)



入力ファイル名に定義されたアクションを表示する例を次に示します。この例では、ユーザーが定義されたアクションの 1 つを選択すると、選択されたアクションおよび入力ファイル名を使用して新しいプロセスが開始されます。
Public Shared Sub PromptForProcessVerb(fileName As String) If Not (fileName Is Nothing) AndAlso fileName.Length > 0 Then ' Display the verbs associated with the input ' file name. Dim startInfo As ProcessStartInfo startInfo = New ProcessStartInfo(fileName) Dim i As Int32 = 1 Console.WriteLine("Supported verbs associated with {0}: ", _ fileName) Dim verb As String For Each verb In startInfo.Verbs Console.WriteLine(" {0}. {1}", i.ToString(), verb) i += 1 Next verb ' Check if the user wants to start the process with ' one of the verbs. If startInfo.Verbs.Length > 0 AndAlso _ File.Exists(fileName) Then i = 0 Console.Write("Select a verb using its index, ") Console.WriteLine("or press Enter to exit: ") Dim input As String = Console.ReadLine() If Not (input Is Nothing) AndAlso input.Length > 0 Then Try i = Int32.Parse(input) Catch e As FormatException i = 0 End Try End If ' If the index is within range, start ' the process using the selected verb. If i > 0 AndAlso i <= startInfo.Verbs.Length Then Console.WriteLine("Type additional process/verb arguments or press Enter to exit: ") input = Console.ReadLine() startInfo.Verb = startInfo.Verbs((i - 1)) Console.WriteLine() If Not input Is Nothing AndAlso input.Length > 0 startInfo.Arguments = input Console.WriteLine("Starting process: {0} {1} {2}", _ startInfo.Verb, startInfo.FileName, startInfo.Arguments) Else Console.WriteLine("Starting process: {0} {1}", _ startInfo.Verb, startInfo.FileName) End If Dim newProcess As New Process() newProcess.StartInfo = startInfo Try newProcess.Start() Console.WriteLine("{0} started successfully with verb ""{1}""!", _ newProcess.ProcessName, startInfo.Verb) Catch e As System.ComponentModel.Win32Exception Console.WriteLine(" Win32Exception caught!") Console.WriteLine(" Win32 error = {0}", e.Message) Catch e As System.InvalidOperationException ' Catch this exception if the process exits quickly, ' and the properties are not accessible. Console.WriteLine("File {0} started with verb {1}", _ startInfo.FileName, startInfo.Verb) End Try End If End If Else Console.WriteLine("Invalid or empty input file name.") End If End Sub
public static void PromptForProcessVerb(String fileName) { if ((fileName != null) && (fileName.Length > 0)) { // Display the verbs associated with the input // file name. ProcessStartInfo startInfo; startInfo = new ProcessStartInfo(fileName); Int32 i=1; Console.WriteLine("Supported verbs associated with {0}: ", fileName); foreach (String verb in startInfo.Verbs) { Console.WriteLine(" {0}. {1}", i.ToString(), verb); i++; } // Check if the user wants to start the process with // one of the verbs. if ((startInfo.Verbs.Length > 0) && (File.Exists(fileName))) { i = 0; Console.Write("Select a verb using its index, "); Console.WriteLine("or press Enter to exit: "); String input = Console.ReadLine(); if ((input != null) && (input.Length > 0)) { try { i = Int32.Parse(input); } catch (FormatException) { i = 0; } } // If the index is within range, start // the process using the selected verb. if ((i > 0) && (i <= startInfo.Verbs.Length)) { Console.WriteLine("Type additional process/verb arguments or press Enter to exit: "); input = Console.ReadLine(); startInfo.Verb = startInfo.Verbs[i-1]; Console.WriteLine(); if ((input != null) && (input.Length > 0)) { startInfo.Arguments = input; Console.WriteLine("Starting process: {0} {1} {2}", startInfo.Verb, startInfo.FileName, startInfo.Arguments); } else { Console.WriteLine("Starting process: {0} {1}", startInfo.Verb, startInfo.FileName); } Process newProcess = new Process(); newProcess.StartInfo = startInfo; try { newProcess.Start(); Console.WriteLine( "{0} started successfully with verb \"{1}\"!", newProcess.ProcessName, startInfo.Verb); } catch (System.ComponentModel.Win32Exception e) { Console.WriteLine(" Win32Exception caught!"); Console.WriteLine(" Win32 error = {0}", e.Message); } catch (System.InvalidOperationException) { // Catch this exception if the process exits quickly, // and the properties are not accessible. Console.WriteLine("File {0} started with verb {1}" , startInfo.FileName, startInfo.Verb); } } } } else { Console.WriteLine("Invalid or empty input file name."); } }
void PromptForProcessVerb( String^ fileName ) { if ( (fileName != nullptr) && (fileName->Length > 0) ) { // Display the verbs associated with the input // file name. ProcessStartInfo^ startInfo; startInfo = gcnew ProcessStartInfo( fileName ); Int32 i = 1; Console::WriteLine( "Supported verbs associated with {0}: ", fileName ); System::Collections::IEnumerator^ myEnum1 = startInfo->Verbs->GetEnumerator(); while ( myEnum1->MoveNext() ) { String^ verb = safe_cast<String^>(myEnum1->Current); Console::WriteLine( " {0}. {1}", i, verb ); i++; } // Check if the user wants to start the process with // one of the verbs. if ( (startInfo->Verbs->Length > 0) && (File::Exists( fileName )) ) { i = 0; Console::Write( "Select a verb using its index, " ); Console::WriteLine( "or press Enter to exit: " ); String^ input = Console::ReadLine(); if ( (input != nullptr) && (input->Length > 0) ) { try { i = Int32::Parse( input ); } catch ( FormatException^ ) { i = 0; } } // If the index is within range, start // the process using the selected verb. if ( (i > 0) && (i <= startInfo->Verbs->Length) ) { Console::WriteLine( "Type additional process/verb arguments or press Enter to exit: " ); input = Console::ReadLine(); startInfo->Verb = startInfo->Verbs[ i - 1 ]; Console::WriteLine(); if ( (input != nullptr) && (input->Length > 0) ) { startInfo->Arguments = input; Console::WriteLine( "Starting process: {0} {1} {2}", startInfo->Verb, startInfo->FileName, startInfo->Arguments ); } else { Console::WriteLine( "Starting process: {0} {1}", startInfo->Verb, startInfo->FileName ); } Process^ newProcess = gcnew Process; newProcess->StartInfo = startInfo; try { newProcess->Start(); Console::WriteLine( "{0} started successfully with verb \"{1}\"!", newProcess->ProcessName, startInfo->Verb ); } catch ( System::ComponentModel::Win32Exception^ e ) { Console::WriteLine( " Win32Exception caught!" ); Console::WriteLine( " Win32 error = {0}", e->Message ); } catch ( System::InvalidOperationException^ ) { // Catch this exception if the process exits quickly, // and the properties are not accessible. Console::WriteLine( "File {0} started with verb {1}", startInfo->FileName, startInfo->Verb ); } } } } else { Console::WriteLine( "Invalid or empty input file name." ); } }

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からProcessStartInfo.Verbs プロパティを検索する場合は、下記のリンクをクリックしてください。

- ProcessStartInfo.Verbs プロパティのページへのリンク