Process.MainWindowTitle Özellik

Tanım

İşlemin ana penceresinin başlık alır.

public:
 property System::String ^ MainWindowTitle { System::String ^ get(); };
public string MainWindowTitle { get; }
member this.MainWindowTitle : string
Public ReadOnly Property MainWindowTitle As String

Özellik Değeri

İşlemin ana pencere başlığı.

Özel durumlar

MainWindowTitle İşlemden çıkıldığından özellik tanımlanmadı.

Uzak bilgisayarda çalışan bir işlemin özelliğine erişmeye MainWindowTitle çalışıyorsunuz. Bu özellik yalnızca yerel bilgisayarda çalışan işlemler için kullanılabilir.

Örnekler

Aşağıdaki örnek Bir Not Defteri örneği başlatır ve işlemin ana penceresinin başlık alır.

#using <System.dll>

using namespace System;
using namespace System::Diagnostics;
int main()
{
   try
   {
      
      // Create an instance of process component.
      Process^ myProcess = gcnew Process;
      
      // Create an instance of 'myProcessStartInfo'.
      ProcessStartInfo^ myProcessStartInfo = gcnew ProcessStartInfo;
      myProcessStartInfo->FileName = "notepad";
      myProcess->StartInfo = myProcessStartInfo;
      
      // Start process.
      myProcess->Start();
      
      // Allow the process to finish starting.
      myProcess->WaitForInputIdle();
      Console::Write( "Main window Title : {0}", myProcess->MainWindowTitle );
      myProcess->CloseMainWindow();
      myProcess->Close();
   }
   catch ( Exception^ e ) 
   {
      Console::Write( " Message : {0}", e->Message );
   }

}
using System;
using System.Diagnostics;

class MainWindowTitleClass
{
    public static void Main()
    {
        try
        {
            // Create an instance of process component.
            using (Process myProcess = new Process())
            {
                // Create an instance of 'myProcessStartInfo'.
                ProcessStartInfo myProcessStartInfo = new ProcessStartInfo();
                myProcessStartInfo.FileName = "notepad";
                myProcess.StartInfo = myProcessStartInfo;
                // Start process.
                myProcess.Start();
                // Allow the process to finish starting.
                myProcess.WaitForInputIdle();
                Console.Write("Main window Title : " + myProcess.MainWindowTitle);

                myProcess.CloseMainWindow();
            }
        }
        catch (Exception e)
        {
            Console.Write($" Message : {e.Message}");
        }
    }
}
Imports System.Diagnostics

Class MainWindowTitleClass
    Public Shared Sub Main()
        Try
            ' Create an instance of process component.
            Using myProcess As New Process()
                ' Create an instance of 'myProcessStartInfo'.
                Dim myProcessStartInfo As New ProcessStartInfo()
                myProcessStartInfo.FileName = "notepad"
                myProcess.StartInfo = myProcessStartInfo
                ' Start process.
                myProcess.Start()
                ' Allow the process to finish starting.
                myProcess.WaitForInputIdle()
                Console.Write("Main window Title : " + myProcess.MainWindowTitle)

                myProcess.CloseMainWindow()
            End Using
        Catch e As Exception
            Console.Write($" Message : {e.Message}")
        End Try
    End Sub
End Class

Açıklamalar

Bir işlemin kendisiyle ilişkilendirilmiş bir ana penceresi olması için işlemin grafik arabirime sahip olması gerekir. İlişkili işlemin ana penceresi yoksa (yani MainWindowHandle sıfırdır) veya sistem bir ana pencere olduğunu belirleyemiyorsa (bazı Unix platformlarında böyle olabilir), MainWindowTitle boş bir dizedir ("").

Bir işlemi yeni başlattıysanız ve ana pencere başlığını kullanmak istiyorsanız, işlemin başlatılmasını tamamlamak ve ana pencere tutamacını oluşturulduğundan emin olmak için yöntemini kullanmayı WaitForInputIdle göz önünde bulundurun. Aksi takdirde sistem bir özel durum oluşturur.

Not

Ana pencere şu anda odakta olan penceredir; bunun işlemin birincil penceresi olmayabileceğini unutmayın. Değiştirildiğinde en güncel ana pencere tutamacını Process almak için nesnesini yenilemek için yöntemini kullanmanız Refresh gerekir.

Şunlara uygulanır