SystemEvents イベント

名前 | 説明 | |
---|---|---|
![]() | DisplaySettingsChanged | ユーザーが表示設定を変更すると発生します。 |
![]() | DisplaySettingsChanging | 表示設定が変更されているときに発生します。 |
![]() | EventsThreadShutdown | システム イベントを待機するスレッドが終了する前に発生します。 |
![]() | InstalledFontsChanged | ユーザーがシステム フォントを追加するか、またはシステム フォントを削除すると発生します。 |
![]() | LowMemory | システムで使用可能な RAM が不足すると発生します。 |
![]() | PaletteChanged | ユーザーが、別のパレットを使用するアプリケーションに切り替えると発生します。 |
![]() | PowerModeChanged | ユーザーがシステムを中断または再開すると発生します。 |
![]() | SessionEnded | ユーザーがシステムからログオフするか、システムをシャットダウンすると発生します。 |
![]() | SessionEnding | ユーザーがシステムからログオフしようとした場合、またはシステムをシャットダウンしようとした場合に発生します。 |
![]() | SessionSwitch | 現在ログインしているユーザーが変更された場合に発生します。 |
![]() | TimeChanged | ユーザーがシステム時間を変更すると発生します。 |
![]() | TimerElapsed | ウィンドウ タイマ間隔が経過したときに発生します。 |
![]() | UserPreferenceChanged | ユーザー設定が変更されると発生します。 |
![]() | UserPreferenceChanging | ユーザー設定を変更しているときに発生します。 |

SystemEvents クラス
アセンブリ: System (system.dll 内)


SystemEvents クラスは、システム イベントの特定の型に応答する機能を提供します。
システム イベントが発生すると、システム イベントを監視するスレッドを使って、イベントに結びつけられたデリゲートがすべて呼び出されます。したがって、イベント ハンドラからのすべての呼び出しをスレッド セーフにする必要があります。このクラスのメンバとしては公開されていないシステム イベントを呼び出す必要がある場合は、InvokeOnEventsThread メソッドを使用できます。
![]() |
---|
このクラスに適用される HostProtectionAttribute 属性には、Resources プロパティ値として MayLeakOnAbort が設定されています。HostProtectionAttribute は、デスクトップ アプリケーション (通常、アイコンのダブルクリック、コマンドの入力、またはブラウザへの URL の入力により起動されるもの) には影響しません。詳細については、HostProtectionAttribute クラスのトピックまたは「SQL Server プログラミングとホスト保護属性」を参照してください。 |

システム イベントに対象を登録してイベントの発生を待機するコード例を次に示します。ここに示す出力は、ユーザーがディスプレイ解像度を変更した場合に発生します。
Imports System Imports Microsoft.Win32 Imports System.Windows.Forms Friend Class Form1 Inherits System.Windows.Forms.Form Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Set the SystemEvents class to receive event notification 'when a user preference changes, the palette changes, or 'when display settings change. AddHandler SystemEvents.UserPreferenceChanging, _ AddressOf SystemEvents_UserPreferenceChanging AddHandler SystemEvents.PaletteChanged, _ AddressOf SystemEvents_PaletteChanged AddHandler SystemEvents.DisplaySettingsChanged, _ AddressOf SystemEvents_DisplaySettingsChanged End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub Private components As System.ComponentModel.IContainer <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.SuspendLayout() ' 'Form1 ' Me.ClientSize = New System.Drawing.Size(648, 398) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub ' This method is called when a user preference changes. Private Sub SystemEvents_UserPreferenceChanging( _ ByVal sender As Object, _ ByVal e As UserPreferenceChangingEventArgs) MessageBox.Show("UserPreferenceChanging: " & _ e.Category.ToString()) End Sub ' This method is called when the palette changes. Private Sub SystemEvents_PaletteChanged( _ ByVal sender As Object, _ ByVal e As EventArgs) MessageBox.Show("PaletteChanged") End Sub ' This method is called when the display settings change. Private Sub SystemEvents_DisplaySettingsChanged( _ ByVal sender As Object, _ ByVal e As EventArgs) MessageBox.Show("The display settings changed.") End Sub End Class
using System; using Microsoft.Win32; public sealed class App { static void Main() { // Set the SystemEvents class to receive event notification when a user // preference changes, the palette changes, or when display settings change. SystemEvents.UserPreferenceChanging += new UserPreferenceChangingEventHandler(SystemEvents_UserPreferenceChanging); SystemEvents.PaletteChanged += new EventHandler(SystemEvents_PaletteChanged); SystemEvents.DisplaySettingsChanged += new EventHandler(SystemEvents_DisplaySettingsChanged); // For demonstration purposes, this application sits idle waiting for events. Console.WriteLine("This application is waiting for system events."); Console.WriteLine("Press <Enter> to terminate this application."); Console.ReadLine(); } // This method is called when a user preference changes. static void SystemEvents_UserPreferenceChanging(object sender, UserPreferenceChangingEventArgs e) { Console.WriteLine("The user preference is changing. Category={0}", e.Category); } // This method is called when the palette changes. static void SystemEvents_PaletteChanged(object sender, EventArgs e) { Console.WriteLine("The palette changed."); } // This method is called when the display settings change. static void SystemEvents_DisplaySettingsChanged(object sender, EventArgs e) { Console.WriteLine("The display settings changed."); } } // This code produces the following output. // // This app is waiting for system events. // Press <Enter> to terminate this application. // Display Settings changed. // User preference is changing. Category=General
#using <System.dll> using namespace System; using namespace Microsoft::Win32; // This method is called when a user preference changes. void SystemEvents_UserPreferenceChanging(Object^ sender, UserPreferenceChangingEventArgs^ e) { Console::WriteLine("The user preference is changing. Category={0}" , e->Category); } // This method is called when the palette changes. void SystemEvents_PaletteChanged(Object^ sender, EventArgs^ e) { Console::WriteLine("The palette changed."); } // This method is called when the display settings change. void SystemEvents_DisplaySettingsChanged(Object^ sender, EventArgs^ e) { Console::WriteLine("The display settings changed."); } int main() { // Set the SystemEvents class to receive event notification // when a user preference changes, the palette changes, or // when display settings change. SystemEvents::UserPreferenceChanging += gcnew UserPreferenceChangingEventHandler( SystemEvents_UserPreferenceChanging); SystemEvents::PaletteChanged += gcnew EventHandler(SystemEvents_PaletteChanged); SystemEvents::DisplaySettingsChanged += gcnew EventHandler(SystemEvents_DisplaySettingsChanged); // For demonstration purposes, this application sits idle // waiting for events. Console::WriteLine("This application is waiting for system events."); Console::WriteLine("Press <Enter> to terminate this application."); Console::ReadLine(); } // This code produces the following output. // // This app is waiting for system events. // Press <Enter> to terminate this application. // Display Settings changed. // User preference is changing. Category=General


Microsoft.Win32.SystemEvents


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


SystemEvents メソッド

名前 | 説明 | |
---|---|---|
![]() | CreateTimer | システム イベント ウィンドウに関連付けられた新しいウィンドウ タイマを作成します。 |
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | InvokeOnEventsThread | システム イベントを待機するスレッドを使って指定したデリゲートを呼び出します。 |
![]() | KillTimer | 特定の ID によって指定されたタイマが終了します。 |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

SystemEvents メンバ
システム イベント通知へのアクセスを提供します。このクラスは継承できません。
SystemEvents データ型で公開されるメンバを以下の表に示します。

名前 | 説明 | |
---|---|---|
![]() | CreateTimer | システム イベント ウィンドウに関連付けられた新しいウィンドウ タイマを作成します。 |
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | InvokeOnEventsThread | システム イベントを待機するスレッドを使って指定したデリゲートを呼び出します。 |
![]() | KillTimer | 特定の ID によって指定されたタイマが終了します。 |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | DisplaySettingsChanged | ユーザーが表示設定を変更すると発生します。 |
![]() | DisplaySettingsChanging | 表示設定が変更されているときに発生します。 |
![]() | EventsThreadShutdown | システム イベントを待機するスレッドが終了する前に発生します。 |
![]() | InstalledFontsChanged | ユーザーがシステム フォントを追加するか、またはシステム フォントを削除すると発生します。 |
![]() | LowMemory | システムで使用可能な RAM が不足すると発生します。 |
![]() | PaletteChanged | ユーザーが、別のパレットを使用するアプリケーションに切り替えると発生します。 |
![]() | PowerModeChanged | ユーザーがシステムを中断または再開すると発生します。 |
![]() | SessionEnded | ユーザーがシステムからログオフするか、システムをシャットダウンすると発生します。 |
![]() | SessionEnding | ユーザーがシステムからログオフしようとした場合、またはシステムをシャットダウンしようとした場合に発生します。 |
![]() | SessionSwitch | 現在ログインしているユーザーが変更された場合に発生します。 |
![]() | TimeChanged | ユーザーがシステム時間を変更すると発生します。 |
![]() | TimerElapsed | ウィンドウ タイマ間隔が経過したときに発生します。 |
![]() | UserPreferenceChanged | ユーザー設定が変更されると発生します。 |
![]() | UserPreferenceChanging | ユーザー設定を変更しているときに発生します。 |

- SystemEventsのページへのリンク