Process.MainWindowTitle 속성

정의

프로세스의 주 창에 대한 캡션을 가져옵니다.

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

속성 값

프로세스의 주 창 제목입니다.

예외

프로세스가 종료되었으므로 MainWindowTitle 속성이 정의되지 않았습니다.

원격 컴퓨터에서 실행 중인 프로세스에 대한 MainWindowTitle 속성에 액세스하려고 합니다. 이 속성은 로컬 컴퓨터에서 실행되는 프로세스에만 사용할 수 있습니다.

예제

다음 예제에서는 메모장의 instance 시작하고 프로세스의 기본 창의 캡션 검색합니다.

#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

설명

프로세스에 그래픽 인터페이스가 있는 경우에만 프로세스에 연결된 기본 창이 있습니다. 연결된 프로세스에 기본 창(MainWindowHandle0)이 없거나 시스템에서 기본 창이 있는지 확인할 수 없는 경우(예: 일부 Unix 플랫폼의 경우일 수 있음) MainWindowTitle 는 빈 문자열("")입니다.

프로세스를 시작했고 기본 창 제목을 사용하려는 경우 메서드를 사용하여 WaitForInputIdle 프로세스가 시작되도록 허용하고 기본 창 핸들이 만들어졌는지 확인하는 것이 좋습니다. 그렇지 않으면 시스템에서 예외가 throw됩니다.

참고

기본 창은 현재 포커스가 있는 창입니다. 프로세스의 기본 창이 아닐 수도 있습니다. 변경된 Refresh 경우 개체를 최신 기본 창 핸들을 얻으려면 메서드를 사용하여 개체를 새로 고쳐 Process 야 합니다.

적용 대상