ProcessStartInfo.Verbs プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ProcessStartInfo.Verbs プロパティの意味・解説 

ProcessStartInfo.Verbs プロパティ

FileName プロパティ指定したファイル種類関連付けられている動詞セット取得します

名前空間: System.Diagnostics
アセンブリ: 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." );
   }
}


プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ProcessStartInfo クラス
ProcessStartInfo メンバ
System.Diagnostics 名前空間
ProcessStartInfo.Verb プロパティ


このページでは「.NET Framework クラス ライブラリ リファレンス」からProcessStartInfo.Verbs プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からProcessStartInfo.Verbs プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からProcessStartInfo.Verbs プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

ProcessStartInfo.Verbs プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ProcessStartInfo.Verbs プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS