using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; namespace Apewer.Internals.Interop { internal class SHCore { /// Retrieves the dots per inch (dpi) awareness of the specified process. /// Handle of the process that is being queried. If this parameter is NULL, the current process is queried. /// The DPI awareness of the specified process. Possible values are from the PROCESS_DPI_AWARENESS enumeration. /// 最小支持 Windows 8.1 及 Windows Server 2012 R2。 [DllImport("SHCore.dll", SetLastError = true)] public static extern void GetProcessDpiAwareness(IntPtr hprocess, out PROCESS_DPI_AWARENESS awareness); [DllImport("SHCore.dll", SetLastError = true)] public static extern bool SetProcessDpiAwareness(PROCESS_DPI_AWARENESS awareness); public enum PROCESS_DPI_AWARENESS { /// DPI unaware.
/// This app does not scale for DPI changes and is always assumed to have a scale factor of 100% (96 DPI).
/// It will be automatically scaled by the system on any other DPI setting.
Process_DPI_Unaware = 0, /// System DPI aware.
/// This app does not scale for DPI changes.
/// It will query for the DPI once and use that value for the lifetime of the app.
/// If the DPI changes, the app will not adjust to the new DPI value.
/// It will be automatically scaled up or down by the system when the DPI changes from the system value.
Process_System_DPI_Aware = 1, /// Per monitor DPI aware.
/// This app checks for the DPI when it is created and adjusts the scale factor whenever the DPI changes.
/// These applications are not automatically scaled by the system.
Process_Per_Monitor_DPI_Aware = 2 } } }