private static async Task <string> GetResolutionExtensionAsync(string url) { DEVMODE devMode = default; devMode.dmSize = (short)Marshal.SizeOf(devMode); NativeMethods.EnumDisplaySettings(null, ENUM_CURRENT_SETTINGS, ref devMode); var widthByHeight = devMode.dmPelsWidth + "x" + devMode.dmPelsHeight; var potentialExtension = $"_{widthByHeight}.jpg"; if (await WebsiteExistsAsync(url + potentialExtension)) { logger.Information($"Background for {widthByHeight} found."); return(potentialExtension); } logger.Information($"No background for {widthByHeight} was found. Using 1920x1080 instead."); return("_1920x1080.jpg"); }
internal static extern bool EnumDisplaySettings(string deviceName, int modeNum, ref DEVMODE devMode);