.NET 命名空间:Microsoft.Win32 与 System 深入解析
1. Microsoft.Win32 命名空间概述
Microsoft.Win32 命名空间提供了与 Microsoft Windows 平台交互的类型,主要集中在两个方面:接收操作系统事件和操作注册表。该命名空间中的类、委托和枚举为 Windows API 中的一些选定函数提供了类型安全的对象包装。
2. 电源模式相关类与枚举
- PowerModeChangedEventArgs 类 :为
PowerModeChangedEventHandler
委托创建自定义的System.EventArgs
对象,提供系统进入的新电源模式信息。
public class PowerModeChangedEventArgs : EventArgs {
// Public Constructors
public PowerModeChangedEventArgs(PowerModes mode);
// Public Instance Properties
public PowerModes Mode { get; }
}
- PowerModeChangedEventHandler 委托 :定义了用于接收
SystemEvents.PowerModeChanged