次の方法で共有


Process.MainWindowTitle プロパティ

プロセスのメイン ウィンドウのキャプションを取得します。

名前空間: System.Diagnostics
アセンブリ: System (system.dll 内)

構文

'宣言
Public ReadOnly Property MainWindowTitle As String
'使用
Dim instance As Process
Dim value As String

value = instance.MainWindowTitle
public string MainWindowTitle { get; }
public:
property String^ MainWindowTitle {
    String^ get ();
}
/** @property */
public String get_MainWindowTitle ()
public function get MainWindowTitle () : String

プロパティ値

プロセスのメイン ウィンドウのタイトル。

例外

例外の種類 条件

PlatformNotSupportedException

プラットフォームが Windows 98 または Windows Millennium Edition (Windows Me) です。Windows 98 や Windows Me でこのプロパティにアクセスするには、ProcessStartInfo.UseShellExecutefalse に設定します。

解説

プロセスに関連付けられたメイン ウィンドウがあるのは、そのプロセスにグラフィカル インターフェイスがある場合だけです。関連付けられたプロセスにメイン ウィンドウがない場合 (MainWindowHandle がゼロの場合)、MainWindowTitle は空の文字列 ("") です。プロセスを起動した直後にメイン ウィンドウのタイトルを使用する場合は、WaitForInputIdle メソッドを使用してプロセスの起動を終了し、メイン ウィンドウ ハンドルが作成されたことを確認してください。確認しない場合、例外がスローされます。

Windows 98, Windows Millennium Edition プラットフォームメモ : ProcessStartInfo.UseShellExecutetrue を設定してプロセスを開始した場合、このプロパティは、このプラットフォームでは利用できません。

使用例

メモ帳のインスタンスを起動し、そのプロセスのメイン ウィンドウのキャプションを取得する例を次に示します。

Imports System
Imports System.Diagnostics

Class MainWindowTitleClass
   Public Shared Sub Main()
      Try

         ' Create an instance of process component.
         Dim 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()
         myProcess.Close()
      Catch e As Exception
         Console.Write(" Message : " + e.Message)
      End Try
   End Sub 'Main
End Class 'MainWindowTitleClass
using System;
using System.Diagnostics;

class MainWindowTitleClass
{
   public static void Main()
   {
      try
      {

         // Create an instance of process component.
         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();
         myProcess.Close();
      }
      catch(Exception e)
      {
         Console.Write(" Message : " + e.Message);
      }
    
   }
}
#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 );
   }

}

.NET Framework のセキュリティ

プラットフォーム

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。

バージョン情報

.NET Framework

サポート対象 : 2.0、1.1、1.0

参照

関連項目

Process クラス
Process メンバ
System.Diagnostics 名前空間