You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
2.1 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Runtime.InteropServices;
  4. using System.Text;
  5. namespace Apewer.Internals.Interop
  6. {
  7. internal class SHCore
  8. {
  9. /// <summary>Retrieves the dots per inch (dpi) awareness of the specified process.</summary>
  10. /// <param name="hprocess">Handle of the process that is being queried. If this parameter is NULL, the current process is queried.</param>
  11. /// <param name="awareness">The DPI awareness of the specified process. Possible values are from the PROCESS_DPI_AWARENESS enumeration.</param>
  12. /// <remarks>最小支持 Windows 8.1 及 Windows Server 2012 R2。</remarks>
  13. [DllImport("SHCore.dll", SetLastError = true)]
  14. public static extern void GetProcessDpiAwareness(IntPtr hprocess, out PROCESS_DPI_AWARENESS awareness);
  15. [DllImport("SHCore.dll", SetLastError = true)]
  16. public static extern bool SetProcessDpiAwareness(PROCESS_DPI_AWARENESS awareness);
  17. public enum PROCESS_DPI_AWARENESS
  18. {
  19. /// <summary>DPI unaware.<br />
  20. /// This app does not scale for DPI changes and is always assumed to have a scale factor of 100% (96 DPI).<br />
  21. /// It will be automatically scaled by the system on any other DPI setting.</summary>
  22. Process_DPI_Unaware = 0,
  23. /// <summary>System DPI aware.<br />
  24. /// This app does not scale for DPI changes.<br />
  25. /// It will query for the DPI once and use that value for the lifetime of the app.<br />
  26. /// If the DPI changes, the app will not adjust to the new DPI value.<br />
  27. /// It will be automatically scaled up or down by the system when the DPI changes from the system value.</summary>
  28. Process_System_DPI_Aware = 1,
  29. /// <summary>Per monitor DPI aware.<br />
  30. /// This app checks for the DPI when it is created and adjusts the scale factor whenever the DPI changes.<br />
  31. /// These applications are not automatically scaled by the system.</summary>
  32. Process_Per_Monitor_DPI_Aware = 2
  33. }
  34. }
  35. }