diff --git a/PiP-Tool.Shared/Helpers/DpiHelper.cs b/PiP-Tool.Shared/Helpers/DpiHelper.cs
index 3240df2..c0dc9d4 100644
--- a/PiP-Tool.Shared/Helpers/DpiHelper.cs
+++ b/PiP-Tool.Shared/Helpers/DpiHelper.cs
@@ -15,11 +15,19 @@ public static class DpiHelper
/// out dpi Y (vertical)
public static void GetDpi(IntPtr hwnd, out float dpiX, out float dpiY)
{
- var handle = NativeMethods.MonitorFromWindow(hwnd, MonitorDefaultTo.MONITOR_DEFAULTTONEAREST);
- NativeMethods.GetDpiForMonitor(handle, MONITOR_DPI_TYPE.MDT_EFFECTIVE_DPI, out var x, out var y);
+ try
+ {
+ var handle = NativeMethods.MonitorFromWindow(hwnd, MonitorDefaultTo.MONITOR_DEFAULTTONEAREST);
+ NativeMethods.GetDpiForMonitor(handle, MONITOR_DPI_TYPE.MDT_EFFECTIVE_DPI, out var x, out var y);
- dpiX = x / 96f;
- dpiY = y / 96f;
+ dpiX = x / 96f;
+ dpiY = y / 96f;
+ }
+ catch (Exception)
+ {
+ dpiX = 1;
+ dpiY = 1;
+ }
}
///