Process.MainWindowTitle Özellik

Tanım

İşlemin ana penceresinin resim yazısını 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 özelliği 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, Not Defteri'nin bir örneğini başlatır ve işlemin ana penceresinin resim yazısını alır.

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}");
        }
    }
}
open System.Diagnostics

try
    // Create an instance of process component.
    use myProcess = new Process()
    // Create an instance of 'myProcessStartInfo'.
    let myProcessStartInfo = ProcessStartInfo()
    myProcessStartInfo.FileName <- "notepad"
    myProcess.StartInfo <- myProcessStartInfo
    // Start process.
    myProcess.Start() |> ignore
    // Allow the process to finish starting.
    myProcess.WaitForInputIdle() |> ignore
    printfn $"Main window Title : {myProcess.MainWindowTitle}"

    myProcess.CloseMainWindow() |> ignore
with e ->
    printfn $" 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ırsa) veya sistem bir ana pencere olduğunu belirleyemiyorsa (örneğin, 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, ana pencere tutamacını WaitForInputIdle oluşturulduğundan emin olarak işlemin başlatılmasını sağlamak için yöntemini kullanmayı göz önünde bulundurun. Aksi takdirde, sistem bir istisna fırlatır.

Note

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

Şunlara uygulanır