private static void SetDpiAwareness(ProcessDPIAwareness val)
 {
     if (Environment.OSVersion.Version.Major >= 6)
     {
         SetProcessDpiAwareness(val);
     }
 }
Beispiel #2
0
 private static void SetDpiAwareness(ProcessDPIAwareness value)
 {
     try
     {
         if (Environment.OSVersion.Version.Major >= 6)
         {
             SetProcessDpiAwareness(value);
         }
     }
     catch (EntryPointNotFoundException)//this exception occures if OS does not implement this API, just ignore it.
     {
     }
 }
Beispiel #3
0
        public static int SetProcessDpiAwareness(ProcessDPIAwareness value)
        {
            //Environment.OSVersion.Version; // reports wrong values
            Version os = WindowsVersionInfo.Version;

            // Windows 8.1 or newer
            if (os.Major > 6 || os.Major == 6 && os.Minor >= 3)
            {
                // We need this, else Windows will fake
                // all the data about monitors inside the application
                return(ShcoreInterop.SetProcessDpiAwareness(ProcessDPIAwareness.ProcessPerMonitorDPIAware));
            }
            return(0);
        }
        /// <summary>
        /// 设置进程 Dpi 感知的类型,
        /// 此函数在 Windows Vista 以及以上的系统中受支持,
        /// 否则调用无效,返回 <see cref="LastErrorCode.UnKnown"/> 未知错误的结果。
        /// </summary>
        public static NativeApiResult <Int32> SetProcessDpiAwareness(ProcessDPIAwareness dpiAwarenessValue)
        {
            NativeApiResult <Int32> result = null;

            if (Environment.OSVersion.Version.Major >= 6 && Environment.OSVersion.Version.Minor >= 2)
            {
                var setResult = SetProcessDpiAwarenessNative((Int32)dpiAwarenessValue);
                result = NativeApiResult.Create(setResult, NativeApiResult.GetLastError());
            }
            else
            {
                result = NativeApiResult.Create(-1, (Int32)LastErrorCode.UnKnown);
            }
            return(result);
        }
Beispiel #5
0
 private static extern int SetProcessDpiAwareness(ProcessDPIAwareness value);
 public static extern int SetProcessDpiAwareness(ProcessDPIAwareness value);
Beispiel #7
0
 internal static extern bool SetProcessDpiAwareness(ProcessDPIAwareness awareness);
Beispiel #8
0
 static extern int SetProcessDpiAwareness([In] ProcessDPIAwareness value);
Beispiel #9
0
 internal static extern void GetProcessDpiAwareness(IntPtr hprocess, out ProcessDPIAwareness awareness);